Reputation: 5375
I am trying to create a framework that can be used in my Apple Watch Extension as well as in the app itself. I did this via creating a new project of the "Watch Framework" type in XCode, and successfully built a framework.
I dragged that into my Apple Watch project, and verified it is in the "Link Binary With Libraries" and "Copy Bundle Resources", and am able to build and deploy to the device.
However, I get the below error message at runtime.
Oct 30 08:14:30 My-s-AppleWatch ReportCrash[187] <Error>: Dyld Error Message:
Dyld Message: Library not loaded: @rpath/SimpleWatchFramework.framework/SimpleWatchFramework
Referenced from: /private/var/mobile/Containers/Bundle/Application/8E7660C0-B741-497C-8251-88D9243234BF/Apple Watch Extension.app/PlugIns/Apple Watch Extension Extension.appex/Apple Watch Extension Extension
Reason: image not found
Dyld Version: 369.12
I looked at the .app directory (under Products) for my main project and can see the framework directory is at the same level as the binary of my Apple Watch Extension (under ../Watch/xxx/PLugins/yyy/), so I am not sure why it is saying it can't find it.
Apple's documentation seems to imply you can do this, but I am not sure if I have to do anything special to gets this to work.
Upvotes: 3
Views: 76
Reputation: 1221
I fixed this problem by ensuring that I added the framework to the embedded binaries section of the watch extension target, rather than the linked framework. Adding it here automatically creates an entry in the linked framework. You can remove the copy bundle resource step too, which copied it into the wrong place (in the root of the app extension). The embedded binaries get the framework placed under a frameworks folder in the root of your extension which is all that's needed for your app to properly load without dyld errors
Upvotes: 1