9

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)

gdavdov
  • 153
  • 1
  • 6

3 Answers3

9

Make use of link_with in your Podfile.

link_with 'appName', 'appName WatchKit Extension'

pod 'Alamofire', :git => "git@github.com:Alamofire/Alamofire.git", :branch => 'xcode-6.3'
pod 'SwiftyJSON', :git => "git@github.com:SwiftyJSON/SwiftyJSON.git", :branch => 'xcode6.3'
theblang
  • 10,215
  • 9
  • 69
  • 120
3

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.

gdavdov
  • 153
  • 1
  • 6
0

I had to update my header search paths in the Build Settings for my watch kit extension target. For my app I made the extension's header search paths match my app's header search paths.

enter image description here

Stephen Johnson
  • 5,293
  • 1
  • 23
  • 37
  • Okay, that definitely sounds like it should be right to me, I also looked into adding Crashlytics to the "Linked Frameworks and Binaries" after seeing your suggestion, but I'm still seeing the same issue. I'll keep at it, but if you think of any other steps or suggestions I'd appreciate it. – gdavdov Dec 18 '14 at 22:16
  • Take a look at the Library Search Paths and make sure they are same in your extension as in your iOS app. – Stephen Johnson Dec 18 '14 at 22:38