xcodecode-signingswift-package-managerdylib

Code signing issue with SPM Dynamic Library


I have a framework (MyFramework) in which I want to use an exsting dynamic framework via SPM (called now MyDynamicFramework).

I included it as a package dependency and all seems to be good: frameworks and libraries

build phases

Then, I created a test application in which I simply include my framework with Embed & Sign.

When I run this test application, it all works fine in simulator, but in real device I get the following signing-related issue:

dyld[24248]: Library not loaded: @rpath/MyDynamicFramework.framework/MyDynamicFramework
  Referenced from: <ED356026-4AD8-3AD4-9CD7-BE977EE551E4> /private/var/containers/Bundle/Application/432B2A6D-55A7-4C9D-8EA2-622B81E215EA/MyFrameworkTestApp.app/Frameworks/MyFramework.framework/MyFramework
  Reason: tried: '/private/var/containers/Bundle/Application/432B2A6D-55A7-4C9D-8EA2-622B81E215EA/MyFrameworkTestApp.app/Frameworks/MyDynamicFramework.framework/MyDynamicFramework' (no such file),
'/private/var/containers/Bundle/Application/432B2A6D-55A7-4C9D-8EA2-622B81E215EA/MyFrameworkTestApp.app/Frameworks/MyFramework.framework/Frameworks/MyDynamicFramework.framework/MyDynamicFramework' (code signature in <2BD920A5-1906-31B6-99B9-18DE47F02514>
'/private/var/containers/Bundle/Application/432B2A6D-55A7-4C9D-8EA2-622B81E215EA/MyFrameworkTestApp.app/Frameworks/MyFramework.framework/Frameworks/MyDynamicFramework.framework/MyDynamicFramework' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.),
'/Users/XXXXXXX/Library/Developer/Xcode/DerivedData/MyFramework-gedzmltwlpgatndvsrwkinsfgwhr/Build/Products/Debug-iphoneos/PackageFrameworks/MyDynamicFramework.framework/MyDynamicFramework' (no such file),
...

Am I missing some settings? I thought that Embed & Sign should have solved the issue but it didn't. Thanks.


Solution

  • You can't distribute nested frameworks. See the relevant Apple Developer Docs regarding this

    iOS and tvOS support frameworks and Swift system libraries at the topmost app level; a nested bundle, like an app extension, can’t include a framework.

    You'll need to achieve your goal in a different way, without nesting frameworks.