I tried to update a Pod that is in swift now.
So I added use_frameworks! into my Podfile and pod install.
I also checked "Embedded Content Contains swift Code" is YES
The error that my other pods that are in Objective-C cannot be found. (file not found)
If I understoof, use_frameworks compiles all pods as frameworks even the objective C ones that don't need that, but anyone can help me fix this issue ?
Do I need to use a Bridging-Header ?
When using frameworks with Swift pods, instead of using a bridging header, in the files that you wish to use the framework in, you just have to import FrameworkName
Related
I have an Objective C project that I added a swift file to - the swift file will contain convenience functions to the rest of my objc project. Adding the swift file triggered adding a bridging header - which I did. All of this works. I also have cocoapods configured and working from objc.
I can call a swift method from objc but my swift file cannot see any of my swift cocoapod modules. I get error 'no such module'. I've searched here extensively and have cleaned my project, cleaned the build folder checked my search paths- all appears ok. I am using use_frameworks! In my pod file.
Any pointers?
You need to add your pod header to your bridging header as described here: Import Objective-C Framework (CocoaPod) into Swift?
Was trying to implement some Obj-C code into my Swift 2 project and decided that I was going to try a different method.
I deleted the files I added, including the newly created bridging header.
I went to build settings and removed the contents of the "Objective-C Bridging Header" setting and now I am getting bombarded with errors.
My project was running fine with no errors prior to the Obj-C fiasco.
Can someone help? See attached image for the errors I am getting.
According to the errors, your swift files (profileVeedVC.swift) still refer to the obj-c code. Remove the pod from your podfile and remove any references within the files.
Good luck!
I have a Swift 2 project running on Xcode 7. I'm using CocoaPods (v 0.38.2 with use_frameworks!) and have already managed to get those frameworks working:
CryptoSwift
Pluralize_swift
Both Pods are written in Swift, so no problems so far. They work as charm.
Now I'm trying to use SMPageControl which is written in Objective-C. I've seen it's possible to use Obj-C Pods with Swift 2, tried a lot of different combinations but I can't get it to work. SMPageControl class doesn't show on autocomplete suggestions, and obviously when I try to use it the compiler throws Use of undeclared type 'SMPageControl'.
What I have done so far:
Added pod 'SMPageControl' to my Podfile
Ran pod install (I can see the Pod source/framework on Xcode project tree)
Added SMPageControl.framework in Build Phases > Link Binary With Libraries (as I've done with the other frameworks that work)
Created PROJECT_NAME-Bridging-Header.h and added it on the project's Build Settings (I can tell it's working because it threw errors until I got to import SMPageControl correctly)
Added #import <SMPageControl/SMPageControl.h> to the file above
Up to here the project compiles without errors, but I can't get to use SMPageControl in my Swift classes. Tried import SMPageControl in the Swift file, but no luck (it doesn't even autocomplete). I understood it's possible, but I didn't find any example codes.
Is it really possible? If so, what am I missing?
Finally got it to work, it turns out that I was actually missing something.
Along with all steps above, it's needed to import the framework at the top of the Swift file:
import SMPageControl
Since Xcode was not providing any autocomplete I thought it wouldn't be possible to do that. Once I added the import statement, the project compiled successfully and I was able to use SMPageControl() class.
I am creating a pod that uses RestKit and a bunch of other pods.
When I am compiling my pod with the command :
pod repo push myCocoapodsRepo myPodspec.podspec --allow-warnings --verbose
The first error I get is
In file included from /var/folders/mx/cg3cmvh14wl2f3mnq0sc_cd00000gn/T/CocoaPods/Lint/Pods/RestKit/Code/ObjectMapping.h:21:
/var/folders/mx/cg3cmvh14wl2f3mnq0sc_cd00000gn/T/CocoaPods/Lint/Pods/RestKit/Code/ObjectMapping/RKObjectMapping.h:23:9: error: include of non-modular header inside framework module 'RestKit.RKObjectMapping' [-Werror,-Wnon-modular-include-in-framework-module]
#import "RKValueTransformers.h"
^
If I rely on other StackOverflow threads about this error, like
Swift compiler error: "non-modular header inside framework module"
Include of non-modular header inside framework module
XCode6: Receiving error "Include of non-modular header inside framework module"
They will all say that setting CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES to YES and/or placing the problematic header file in the Public section instead of the Project section, it will solve the problem. But for me, it does not. Those threads also have in common the Swift language, but I do not use it. I'm still using only Objective-C, but I don't know if it has an impact on my problem.
I do not understand what the error means, therefore I have a lot of difficulty solving the problem. Does someone have another solution?
You should add the flag --use-libraries like this:
pod repo push myCocoapodsRepo myPodspec.podspec --allow-warnings --verbose --use-libraries
When I use cocoapods to add AFNetworking to my workspace, everything appears to be in place but I am unable to instantiate any AFHTTPClient instances in my code. The files: AFHTTPClient.h and .m are not present anywhere within the AFNetworking hierarchy.
Currently, my Podfile looks like this:
platform :ios, '7.0'
pod 'AFNetworking', '~> 2.0'
pod 'Parse', '1.2.17'
And my CLI pod update command runs fine from the terminal as shown below:
nmaster >> pod update
Analyzing dependencies
Downloading dependencies
Using AFNetworking (2.0.3)
Using Facebook-iOS-SDK (3.11.0)
Using Parse (1.2.17)
Generating Pods project
Integrating client project
The error I am seeing in my code is shown below:
I've seen a number of posts referring to the HEADER SEARCH PATH being insufficient but I've already confirmed that the files themselves do not exist. Has AFHTTPClient been deprecated? I did find a copy in one of Ray W.'s tutorials of both the AFHTTPClient.h and .m files and tried to drag/drop those into my project but that led to duplicate references and other problemos.
Anyone have any ideas of where I should attack this problem?
Thanks, Phil
AFHTTPClient has been replaced by other classes in AFNetworking version 2.0. See also here: https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-2.0-Migration-Guide. If you specify version 1.6.x (from memory) and iOS 6.1 in your podfile, you can still use the old version and keep your code.