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!
Related
I am using the GoogleMaps iOS SDK in my app and added it with cocoapods. However, after updating xCode from 7.0 to 7.1 I'm suddenly getting the following error: Could not build Objective-C module 'GoogleMaps'
In addition xCode also gives me an error in the GoogleMaps.h file in the GoogleMaps.framework:
Include of non-modular header inside framework module 'GoogleMaps'
I already deleted my DerivedData folder, updated cocoapods, reinstalled the GoogleMaps iOS SDK and cleaned and build the framework's scheme and my app's scheme. But nothing helped so far.
Answered in this similar question: xCode 7 error: include of non-modular header inside framework module with Google Maps
...but essentially you'll need to create an Objective-C bridging header file whereas you may not have needed one with Xcode 7.0. The why still eludes me.
you should open the .xcworkspace not .xcodeproj
once you added cocoa pods your project folder will contain the .xcworkspace file
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!
I'm attempting to compile a Swift app with supplementary Objective-C files loaded via the bridging header. However, it gets as far as the first line:
#import <Foundation/Foundation.h>
and shows the error:
Could not build the module 'Foundation'
I've checked that the Foundation framework is included but no luck. I've tried various combinations of deployment targets, architectures, etc too. Has anyone else experienced this in Xcode 6 beta 5?
Doc says
Any Objective-C framework (or C library) that’s accessible as a module
can be imported directly into Swift. This includes all of the
Objective-C system frameworks—such as Foundation, UIKit, and SpriteKit
so you could just do
import Foundation
You cannot import Obj-C-Headers in C-Files.
(If you are using c in your project).
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.
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!