How to use objectiveC and swift libraries Cocoa Pods - objective-c

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.

Related

Import Objective-C files breaks CocoaPod

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.

Creating framework with Cocoapods 0.36 in objective-C

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>

Xcode 6.2/Parse 1.6.4: Definition of 'PFFile' must be imported from module

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>

PhoneGap template-based app failing to compile AdWhirl sources

Using Xcode4.2.1, with a basic PhoneGap template based app. (I say template, but I cant find it now :( - PhoneGap is a static framework).
The app works ok on its own.
Now trying to add in AdWhirl. AdWhirl comes as source files - no library of its own, although there are libraries for the specific ad services you use.
I have added the folders to the project, but it does not seem to compile the AdWhirl sources - if amend/break the AdWhirl code, I get no compile errors.
Where I have included/imported the AdWhirl headers into my app, I had to tweak the related imports in AdWhirl files to find their dependancies - seems to be related to issue above.
I can get it compiling with that hack - but then fails to link - missing AdWhirlView, which also seems to be due to first issue - not being compiled, so not available to link.
Under build phases/compile sources, I have just 2 items: main.m and AppDelegate.m - do I need to add the AdWhirl code into here?
Here is a sample project with just the AdWhirl stuff, no PhoneGap, but still has the issue :(
Thanks in advance for any tips/pointers.
Just wanted to post the answer here that I gave on Twitter. Seems like the issue is that Xcode is unhappy with folder references. Try reimporting the AdWhirl files into your project, but tell Xcode to add groups for folders, rather than folder references. (Incidentally, if anyone knows why Xcode is choking on the folder references, I'd love to hear about it.)
Then, you'll start getting errors about ARC and missing files pertaining to the Google Ads framework. So, you'll have to add the Google Ads files to quell the errors; then, you'll want to make sure ARC is disabled in your project. If you want to use ARC, then your best bet is to repackage AdWhirl as a static library that builds without ARC, and have that as a dependency in your workspace.

Linking libcsoap to iPhone project in Xcode

I have an iPhone project that I want to use libcsoap in to make service calls. I'm having trouble linking a pure c library to xCode though. I've tried everything short of manually rebuilding the project as an Xcode project.
I built it via command line (./configure; make; make install). Then linked the output (libcsoap.a) and connected to the headers. This gave me a linker error saying that libcsoap.a was built for archiving and couldn't be used.
I tried creating a project out of just the makefile but that failed to build.
Can anybody explain to me what I should do to link these?
Thanks in advance,
George