Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After adding watchkit extension to project, previously added third party frameworks no longer work

Tags:

ios

watchkit

I have an application that is currently working, everything's fine.

When I go to File->New->Target and add a watchkit app/extension the build is immediately broken because "Module 'Crashlytics' not found". Currently, Crashlytics is accessed using @import Crashlytics, I checked the project, and the pbxproj file has the crashlytics framework referenced to the correct location, and Crashlytics.h is visible in the project. I tried switching to #import "Crashlytics.h" just to see if maybe it was something to do with the module as opposed to simply importing the header, but then Crashlytics.h file not found.

Crashlytics has been in the project for a very long time, working perfectly. Is there something extra required when adding in the watch extension while using external frameworks or pods?

(If I comment out the line altogether, just to see what happens, I get a similar issue for one of the cocoapods we're using, and I'd be willing to be if I went along commenting things out I'd end up having to remove anything that's an external framework)

like image 823
gdavdov Avatar asked Dec 18 '14 21:12

gdavdov


2 Answers

Make use of link_with in your Podfile.

link_with 'appName', 'appName WatchKit Extension'

pod 'Alamofire', :git => "[email protected]:Alamofire/Alamofire.git", :branch => 'xcode-6.3'
pod 'SwiftyJSON', :git => "[email protected]:SwiftyJSON/SwiftyJSON.git", :branch => 'xcode6.3'
like image 145
theblang Avatar answered Sep 23 '22 18:09

theblang


I actually found the answer myself. And as usual it was something silly but important. When I added the extension, the third party libraries and frameworks were not automatically added to the target, so I had to go back in and "add files" in order to add the Crashlytics framework into the WatchKit Extension target.

Also, it turns out this is a wider problem. My guess is it's an issue that might happen for any third party library or framework when any extension is added. I also had the issue with my cocoapods, and had to add: link_with 'target1', 'target2' to the podfile to make sure the pods were added to more than just the default first target.

Props to Stephen Johnson though, for this kind of issue the Header and Library search paths are excellent places to check for debugging.

like image 22
gdavdov Avatar answered Sep 23 '22 18:09

gdavdov