问题
I have a project containing another target(framework) which is a dependency of the main project. That framework requires it's own frameworks, so I've added them using carthage. The project compiles and runs fine on simulator, however I'm getting the following error when running it on a physical device:
dyld: Library not loaded: @rpath/Subframework.framework/Subframework
Referenced from: /private/var/mobile/Containers/Bundle/Application/LONG-ID/MyApp.app/Frameworks/MyAppSDK.framework/MyAppSDK
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/LONG-ID/MyApp.app/Frameworks/MyAppSDK.framework/Frameworks/Subframework.framework/Subframework: mmap() error 1 at address=0x00798000, size=0x00060000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/LONG-ID/MyApp.app/Frameworks/MyAppSDK.framework/Frameworks/Subframework.framework/Subframework
I have tried this, however the only solution is to add the Subframework to "Embed frameworks" to top level project, which is not viable. I've tried modifying Build Settings -> Linking -> Dynamic Library Install name, however it didn't help.
How can achieve make it work on the iphone?
回答1:
I was also facing this issue for some time and I had a three level hierarchy where the outer most 'Umbrella Framework' should not be distributed with the other frameworks. How I resolved it was by setting the 'Run Search Paths' under 'Linking' in 'Build Settings' of each of the 'Umbrella Framework' to point to the 'Copy Files' destination that is set in the 'Build Phases' (You have to add a 'Copy Files' build phase and preferable set its' destination to 'Frameworks', then add each 'Sub-framework' you want to embed).
Copy sub-framework to 'Frameworks'
Set 'Runpath Search Paths' to 'Frameworks'
来源:https://stackoverflow.com/questions/36421604/embed-frameworks-inside-a-framework-ios