Search code examples
iosxcode6watchkitapple-watchios-frameworks

Issue with nested Framework for Watchkit Extension


My Watchkit app does not work in production (TestFlight && rejected from AppStore).

I think the issue come from a nested framework. Here the architecture :

I've made a framework "ModelLayer" (Cocoa Touch Framework) with the app's model, so it can be shared across all targets. This framework use another third party framework (UICKeyChainStore.framework). And the apple watch extension use "ModelLayer".

When debugging everything works fine. But when I uploaded the archive on iTunes connect I had an error saying that nested frameworks where not allowed. So I removed the copy file phase that I had in the Build Phase of "ModelLayer"'s target. It did not worked well as the app has been rejected...

I found some threads on internet that says that the copy file phase should have as Destination 'Shared Frameworks' and not 'Frameworks' (as I've done before). So I tried this, I've uploaded a pre-release of my app on itunes connect and tried the app with testflight. The app is now on my Apple Watch, but impossible to load the app. The loader stay on screen.

Did I miss something ? How can I use UICKeyChainStore.framework in my 'ModelLayer' framework ??

Thanks in advance !

Build phases of my framework : ModelLayer

Apple Watch app result via test flight


Solution

  • So I found the solution. The third party framework in my custom framework was not the problem. But It was my custom framework in the watch kit extension. So it's not possible to embed directly a framework in an extension. The framework should be embedded by the main app. And the extension will be able to use it.

    Add the framework to the main app target

    In Build Phases Tab

    enter image description here

    Use the framework in extension target

    In General Tab

    enter image description here

    And in Build Settings Tab -> Linking Add @executable_path/../../Frameworks to Runpath Search Paths

    enter image description here