I am trying to add some Swift code to my existing Objective-C CocoaPod. I have added a bridging header for my example project, but I can't actually get my podspec file to validate as CocoaPods isn't aware of my bridging header file. Anyone know how to fix this issue?
Thanks!
Related
How I can use CryptoSwift to my Objective-C project?
I have an Objective-C project and want to use Encryption Library CryptoSwift for that. I have successfully used the single Swift file into my Objective-C project, but how to use a Swift project as subproject to the parent project that was built in Objective-C.
I tried to use Cocoa pod too but to no avail.
You can use Cocoa pods but on the target at the build options you should set Embedded Content Contains Swift Code to YES.
See this tutorial for a detailed description.
I have installed an obj-c framework in my swift project using cocoapods. In my bridging header file I have imported the framework which works fine.
#import "libPhoneNumber_iOS/NBPhoneNumberUtil.h"
#import "libPhoneNumber_iOS/NBPhoneNumber.h"
However I can't seem to use the classes in my project
let phoneUtil = NBPhoneNumberUtil()
This gives an error that I am using an unresolved identifier.
In my podfile I have use_frameworks!, but I can't import the classes directly in a swift class. In my build settings also I have already set the configuration to use the pod-config file.
The framework works fine if I add it manually to my project (not using cocoapods) and import in my bridging header.
Is this problem a problem with cocoapods or am I doing something wrong? Can't seem to find a way for this to work. Any help would be appreciated. Thanks!
I am working on a Swift project using AFNetworking. I am using Cocoapods to manage my third-party Obj-C libraries and using bridge-header to import them in the Swift codes.
The problem is that I cannot use CMD+click to find the Swift API of those Obj-C classes (I am always led to Obj-C interface or implementation). I have to guess the format of API according to so-called Obj-C Swift Interaction and it is very annoying sometimes.
Is there any way I can directly check the Swift style API of existing Obj-C libraries?
Thanks in advance!
You can use Alamofire (swift version of AFNetworking) : https://github.com/Alamofire/Alamofire
I am trying to create a swift-based iOS 8 framework, and wanted to include Firebase framework into it. The instructions on Firebase site are only for importing Firebase into iOS apps, which uses bridging headers. Per Apple's instructions, bridging headers don't seem to apply to a Swift framework importing an Objective-C framework. I was looking at the Importing External Frameworks section on the Apple link. It specifies that: "When you import an external framework, make sure the Defines Module build setting for the framework you’re importing is set to Yes."
Despite that, I tried to manually create bridging header and adjusted Swift Compiler - Code Generation Building Settings, to no avail.
Would you know if the Firebase framework has Defines Module build setting set to Yes? If it does, then I'll keep digging into why I get "Use of unresolved identifier Firebase" after explicitly following Firebase instructions a few times. I am using Xcode 6 Beta 5. Any other suggestions and work-arounds are also deeply appreciated.
Here is a work-around I tried, that did not work:
In Xcode 6 Beta 5, I created a new Objective-C framework - SwiftFirebase. In it, I
imported Firebase framework, and the other five frameworks
set the -ObjC flag
copied references of all the .h files in Firebase Headers folder into the new framework - SwiftFirebase.
made those references from Project to Public
imported into the SwiftFirebase umbrella header
ensured that Defines Modules was enabled. It was, by default.
Build for Running.
Created a new Swift-based Framework: TestFramework to test the above SwiftFirebase, where I
Added SwiftFirebase from Debug-iphonesimulator into the new library
Created a new swift class
Imported SwiftFirebase
Added an init method, where I put in the sample swift code from Firebase quick-start.
Build for Running
Got an error compiling: "Firebase/Firebase.h not found"
My guess is that copying references of header files from a Firebase into another Objective-C framework and making them public is not an effective way of manipulating files. :)
Hate to wait for Apple's fix. Anything else I could try? Did I miss something in the above steps that you could think of? Many thanks!
So I get the latest VLCKit to compile and I see in the xcode project it has it's Defines Module set to Yes in the project Build Settings, and it has the Product Module Name set to VLCKit.
I run make VLCKit to build the framework, everything builds and I get my VLCKit.framework file.
I embed that framework into my Swift based app.
If I use the bridging header, it complains that it can't find the VLCKit/VLCKit.h
from the swift side import VLCKit is also an error.
Anyone get this to work?
Well I managed to fix the issue by just creating a new project VLCKit won't play in my swift bridged project, which is another issue entirely. It will play in a purely obj-c project though.