Closed chnbz closed 9 years ago
The error looks like you don't import file. Check that you have this string in file
#import "ActionSheetPicker.h"
@m106 any updates?
Sorry Petr,
had no time to try out your suggestion! I hope I will be able to do it this evening and will then get back to you! Thanks for your support!
Ahh, one question: Where does this line need to be?
I have already import CoreActionSheetPicker in my VC and that where I am getting the error. Btw: I am using Swift!
I solved the problem by following this tutorial: https://medium.com/@stigi/swift-cocoapods-da09d8ba6dd2
@m106 great! Thanks for update!
How did you solve this? I have the same issue. Have other pods installed that are working perfectly, but this one says "no such module" when I try to import CoreActionSheetPicker into VC. With latest version of pods we shouldn't have to modify bridging header, but I've tried that too, and just get "file not found" on #Import "ActionSheetPicker.h".
Any help is appreciated!
Hi,
as linked in my previous post, you need to create a bridge header https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
Thank you for the response! Appreciated! I did this, but it keeps saying "File not found" on the link phase. How did you structure the #INPUT line in the header?
Appreciated!
Hi,
this is how my bridge file looks like!
// Bridge.h
#ifndef MyProject_Bridge_h
#define MyProject_Bridge_h
#import <ActionSheetPicker-3.0/AbstractActionSheetPicker.h>
#import <ActionSheetPicker-3.0/ActionSheetCustomPicker.h>
#import <ActionSheetPicker-3.0/ActionSheetDatePicker.h>
#import <ActionSheetPicker-3.0/ActionSheetDistancePicker.h>
#import <ActionSheetPicker-3.0/ActionSheetLocalePicker.h>
#import <ActionSheetPicker-3.0/ActionSheetStringPicker.h>
#import <ActionSheetPicker-3.0/DistancePickerView.h>
#import <ActionSheetPicker-3.0/ActionSheetPicker.h>
#import <TSCurrencyTextField/Core/TSCurrencyTextField.h>
#endif
Don't forget to name the bridge header file in the project settings!
thanks!
I'm facing the same issue. I've followed all the steps but it still doesn't work. My bridging header file looks exactly like yours @m106 and is referenced correctly in target settings.
Hi ez,
Im having the same issue still. I've resorted to copying over the contents of the "Picker" directory to my project, and then adding
to my bridging header. This is old school, and of course its not in pods, but it does work and now I can use this wonderful picker :)
@CigarsNMartinis Thanks! I will look into that. @skywinder seems to me, like this issue isn't really closed yet.
Surething @ezCoding ! Do let me know if you have any other issues, Im working on this right now :P
@CigarsNMartinis Please, check the example projects - there is already imported picker to swift project.
FYI: The Xcode has some difficulties with "-" & "." in the name of framework while trying to import the pod. To import the framework simply add: import ActionSheetPicker_3_0 to your swift file.
@D051p0 thanks! It's about framework integration, right? Should I rename something in this project to simplify integration process or it works as is?
Thank you @D051p0 that actually fixed the issue.
@skywinder renaming it to just ActionSheetPicker would be an option. Alternatively you could put a line in the README stating that to use this lib with swift and cocoa pods, you have to import it as _ActionSheetPicker_30. You should also update the swift examples.
@skywinder Yes, it is. I suppose, the simplest solution would be to rename the pod framework from ActionSheetPicker-3.0 to something like ActionSheetPicker3 or CoreActionSheetPicker. You have to remove all special characters from the name. I hope, I could help you.
@ezCoding @D051p0 renaming of the pod is not good idea, because a lot of people using this name already and I can't notify them all to update to new name.
BDW, why are you use "ActionSheetPicker_3_0"?
All, that you have to write to import all pickers is:
import CoreActionSheetPicker
I just create new project and such import string works fine. Probably I miss something. Please, give more details, in which case this import error occurs.
If you are using CocoaPods to manage dependencies, the CoreActionSheetPicker is not included to the framework. Unfortunately I don't know if it is a new feature of CocoaPods or Xcode, but you have to import the name of the pod in the swift file, where you want to use it. In your case the pod is called ActionSheetPicker-3.0, which will produce the compiler error.
@D051p0 got it! Thanks for clarify!
@D051p0 Hey, what about bridging header for the swift projects? I if I understand it correctly, you shoud anyway to add bridging header, if you are using obj-c code in the swift project.
Just add
#import "ActionSheetPicker.h"
And that's it. (more info: http://stackoverflow.com/questions/24034409/how-to-import-existing-objective-c-classes-in-swift)
Now you don't have to import anything in you swift projects. Just use it like it already imported.
Let me know, if I miss something again :wink:
@skywinder That didn't work with cocoa pods. I had to drag all Header and Member files to my project and create a bridging header file. Cocoa Pods was basically useless for me without knowing that I had to replace '.' and '-' with '_'.
Just add one line to the README explaining that in swift you have to write: _import ActionSheeetPicker_30 and this question shouldn't come up again.
@skywinder You don't need to import Obj-C classes if you are using CocoaPods. There is also no need to use the bridging header. This works in your project because you've imported ActionSheetPicker manually to your project (I suppose the complete xcodeproj). If you create a new empty project, add pod 'ActionSheePicker-3.0' to podfile and install the dependencies, you are not able to import any .h-files in the bridging header. They will be not found. If you add
#import <ActionSheetPicker_3_0/ActionSheetPicker.h>
to the bridging header you will not receive any compiler errors, however you can't use the obj-c-class in swift-classes. There are 2 solutions in my opinion:
import ActionSheetPicker_3_0
at the beginning of the swift-file like this:
import UIKit
import ActionSheetPicker_3_0
class MySwiftViewController: UIViewController {
// define the class
// ....
}
@D051p0 I test it with swift before. have no problems to add bridging header.
I tried your way - just create new project,install pod and import
import ActionSheetPicker_3_0
But got error
No such module 'ActionSheetPicker_3_0'
you can check example in 00af0a6 ( branch feature/add-swift-pod-example )
It's really strange. I've just checked the auto-generated
Pods-DemoApp.release.xcconfig
and
Pods-DemoApp.debug.xcconfig
files in Pods project and found this
FRAMEWORK_SEARCH_PATHS = "$PODS_FRAMEWORK_BUILD_PATH"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
OTHER_CFLAGS = $(inherited) -iquote "$PODS_FRAMEWORK_BUILD_PATH/ActionSheetPicker_3_0.framework/Headers" -iquote {...}
OTHER_LDFLAGS = $(inherited) -ObjC -framework "ActionSheetPicker_3_0" {...}
OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS)
PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-DemoApp
PODS_ROOT = ${SRCROOT}/Pods
As you see, the CocoaPods generate the framework as
ActionSheetPicker_3_0
Unfortunately I can't tell, why it is happening.
@D051p0 Which version of cocoapods are you using? (mine is 0.36.4)
I had the version 0.36.0 and updated to 0.37.1 - No changes
I'm using cocoapods version 0.36.4 and I had to do #import <ActionSheetPicker_3_0/ActionSheetPicker.h>
in my Bridging Header and in my View Controller, I had to do import ActionSheetPicker_3_0
to get things to work. Just confirming what @D051p0 had done.
@schan93 thanks for feedback! I try figure out, what cause requirement of this import.
Because based on https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
Swift will see every header you expose publicly in your umbrella header. The contents of the Objective-C files in that framework will be available in any Swift file within that framework target automatically, without any import statements.
It seems that you don't need write any additional imports. And I don't in my example project with swift + pods. And it works.
Thanks all of you for feedback! Get in touch with this problem.
If someone figure out when and why you need this import - let me know, I want to clarify it in readme
.
@skywinder I've figured it out. There are 2 ways, how to add Pods to the project. Unfortunately each pod developer uses his own Podfile example. 1:
platform :ios, '8.0'
pod 'CocoaAsyncSocket'
pod 'IQKeyboardManager'
pod 'JBChartView'
pod 'ActionSheetPicker-3.0'
pod 'FontAwesomeKit'
2:
platform :ios, '8.0'
use_frameworks!
target 'DemoApp' do
pod 'CocoaAsyncSocket'
pod 'IQKeyboardManager'
pod 'JBChartView'
pod 'ActionSheetPicker-3.0'
pod 'FontAwesomeKit'
end
Even in the CocoaPods instruction and example Podfile is a failure: If you are using
use_frameworks!
target .....
in the Podfile (2), you have to include frameworks as described in Swift manual.
Without using it in Podfile(1), you have to include the header files into bridging-header.h
I hope, I could help you.
@D051p0 :+1: Thanks for your research! I will test it soon!
Also I'm thinking to go back to name ActionSheetPicker
(if I ill able to make reference for both pods to one repository)
D051p0 had it right. As this project is handled in CocoaPods (frameworks) today, using Swift
import ActionSheetPicker_3_0
How he figured that out? no idea. But thanks
@schan93, @D051p0, @levous I updated readme with instructions. Thanks for help!
@schan93, @D051p0, @levous please check issue #190. Probably you have any ideas, what's wrong there?
how to import the library without cocoa in swift?? ..drag and drop files Pickers/* to project .... how to import ActionSheetPicker_3_0 --- :(, my version ios7, no upload program to itunnes with cocoapod
Hi,
I installed the ActionSheetPicker via CocaoPods to my project but still getting the error "No such module 'CoreActionSheetPicker'"! I am opening the .xcworkspace file of my project and the examples are compiling fine!
What am I doing wrong? Any help appreciated!