My setup:
1) Cocoapod of Objective-C class installed in Swift 2.0 project works
2) If I attempt to import another Objective-C class, the addition of a bridging header seems to break the class imported by the Cocoapod.
I have an Cocoapod written in Objective-C I've successfully imported into a Swift 2.0 project. Everything works fine with that Cocoapod. I didn't have to do anything to get it to work--it just "worked".
When I attempt to import another Objective-C class into my project WITHOUT Cocoapods, the addition of the bridging header seems to break my previously imported Cocoapod. The moment I create a bridging header, my project stops seeing the original Cocoapod's classes.
I suspect the new bridging header is breaking something the Cocoapod set up, but I'm unable to find another bridging header in my project. If anyone has suggestions where to look for the issue, I would be grateful for them.
Update
I tried adding the 2nd non-Cocoapod Objective-C class WITHOUT adding a bridging header at the prompt and I get same error. No such module 'CocoaPodClassThatWorkedBefore'
I have no idea why or how this worked, but I went to the command line in my project's directory and reinstalled the Cocoapod using the following:
pod install
I had already installed the Cocoapod, but after adding another non-Cocoapod Objective-C class to a Swift 2.0 project, something got fouled up. Reinstalling the Cocoapod seems to have resolved the issue of Xcode not seeing the original installation.
For those who aren't familiar with Git or Github, I strongly suggest you learn it and have it implemented on your project before attempting this solution. Alternatively, have a clean backup of your project laying around in case it doesn't go according to plan.
Related
I have a project that is mostly Swift, but has some (internal) Objective-C code wrapping around CommonCrypto functions. It took some some tinkering, but we managed to make it work without exposing the internals by making all the headers private and using a bridging header, not added to any target but referenced in build setting "Objective-C Bridging Header" (on the targets, not the project).
Now we decided to move this part of the project into its own framework. So I created a new project (as Cocoa Touch Framework, same as the old), copied over the necessary source files, recreated the bridging header, and expected it to compile.
However, I'm getting
error: using bridging headers with framework targets is unsupported
This is confusing since there is one in the other project, which builds just fine (for iOS and macOS).
I went through all of the build settings, project and target. The only differences are
iOS target version 10.3 (new) vs 10.2 (old),
no signing vs signing (that may just be because the new project never built), and
some static analysis setting about suspicious conversions.
Neither of those should impact this matter. Nevertheless, I confirmed that the new project doesn't build for 10.2, either.
So what's going on here?
I'm currently using Swift for an Objective-C project. Previously, I imported those Objective-C frameworks through bridging header since I did not use any Swift pods. But today, I need to use swift libraries such as Alamofire, which means I will need to use_framework! in my Pod File.
However, here comes the problem, after I pod install, and try to run the project on my device, errors jump up! What is even more odds is that everything works fine on simulator.
The errors are mainly about "Cannot find XX module" / "Cannot find XX local file" in objectiveC files.
I think it must have something to do with "use_frameworks" in cocoa pods. My question is how can I solve this problem? A million thanks beforehand, I have been scratching my head for this the whole day!
Go to Window -> Projects and Delete derived data. Then do a standard rebuild and it should work fine. I have run into this a few times when dealing with changing cocoapods.
Been stuck on this past 2 days
I am trying to create my own dynamic framework on iOS 8.3. I needed to use FMDB in my framework.
With Cocoapods 0.36 installed, I did a pod install on the following Podfile
use_frameworks!
target "PoddedFramework" do
pod 'FMDB'
end
This works just fine and creates the required pod frameworks and workspace.
But, I can't find a way to use the FMDB pod in my own framework or my demo project that uses the framework.
#import <FMDB/FMDB.h>
This statement results in a "Could not build module 'FMDB'" build error in my own framework.
If I include the above statement in the public header of my framework and try to use that public header in my demo project, I get an error saying "File not found" for FMDB.h
I have seen a lot of questions regarding integration with swift, but could not find anything regarding objective-C
I have been working with that framework a few weeks ago and it has been one of my headaches, but yesterday (Feb 6, 2018) after trying many things, I made the following adjustments taking another FMDB project as an example.
After installing FMDB (2.7.2) with "pod install" and opening the .xcworkspace I thought it would be fine and I could use it, but no, I found some differences mainly in the option Search Paths -> Header Search Paths as I show in the image configuration pods Search Paths and configuration FMDBtest Search Paths.
Then link in my viewController.m with #import "FMDB.h", if it does not work, try the option #import <FMDB / FMDB.h>
Today I've updated to Xcode 6.2/iOS SDK 8.2 and I've updated my project's Parse framework to 1.6.4 simultaneously. Now, I'm getting this error:
Definition of 'PFInstallation' must be imported from module 'Parse.PFInstallation' before it is required.
and
Definition of 'PFFile' must be imported from module 'Parse.PFFile' before it is required.
Both manifest as errors, not warnings, though interestingly my app builds.
I think modules are a Swift thing, though I'm on Objective-C and my project has nothing to do with Swift. What should I do?
UPDATE: Cleaning the build folder and restarting Xcode and rebuilding got me rid of the installation one, though file error is still here.
Congratulations!
You've found (yet another) bug in Xcode.
File it on bugreporter.apple.com
Cause it's still there one major release later in xcode 7.2.1
and I have to rm -rf ~/Library/Developer/Xcode/DerivedData all the time
to have the project build and run
(I do have swift content in the outer framework of mine though)
UPD 2016.02.18 this either seems fixed in 7.3 beta 3 OR I have strategically killed an #import somewhere which took care of this. Do not hesitate to share YOUR experience in the comments and/or answers ;-)
Try to import the file with framework reference like this:
#import <Parse/PFInstallation.h>
I have made a library that make by swift cocoa touch framework, and now I need to export it to file .framework that can import for another project. In fact, I'm workground that copy the framework from product forder, but I think it is not a correctly solution (such as it may be archive and export, but I can't do it). Please help me. Thanks.
If I understood correctly you made a swift framework and want to include the framework to another project.
You can just drag the framework .xcodeproj from Finder to your new project and start using it.