Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking only embedded framework with other dynamic framework fails when build & run on device

tl;dr

Linking your embedded framework with other framework and don't link other framework with your app cause required code signature missing when Build & Run on device.

description:

Setup:

My setup is pretty simple (Swift 2.3 & Xcode Xcode 8.0; Build version 8S162m):

  • Using Carthage (0.17.2) I have build Other.framework with xcodebuild 8.0 and TOOLCHAINS=com.apple.dt.toolchain.Swift_2_3 carthage build --platform iOS
  • MyApp has embeded My.framework.
  • The app and the framework projects are under one Xcode workspace.
  • I hade linked Other.framework to My.framework ONLY (that means, MyApp is not linked to Other.framework at all). The point here is that, MyApp does not need to use Other.framework API.

Problem:

Everything seems to work fine, until I Build & Run the app on the device. The app launched and than the process is aborted with the following Xcode error:

dyld: Library not loaded: @rpath/Other.framework/Other  
  Referenced from: /private/var/containers/Bundle/Application/DCF0331F-FF23-43CF-AE79-B3857D5A6EE3/MyApp.app/Frameworks/My.framework/My  
  Reason: no suitable image found.  Did find:  
  /private/var/containers/Bundle/Application/DCF0331F-FF23-43CF-AE79-B3857D5A6EE3/MyApp.app/Frameworks/My.framework/Frameworks/Other.framework/Other: required code signature missing for '/private/var/containers/Bundle/Application/DCF0331F-FF23-43CF-AE79-B3857D5A6EE3/MyApp.app/Frameworks/My.framework/Frameworks/Other.framework/Other'  

I have checked the signature of Other.framework and it looked OK to me. Moreover,

Solution (workaround)

Link MyApp with Other.framework. Horrible... This feels broken.

Linking the very same binary Other.framework to MyApp and solving the issue this way, points out, the Other.framework is built OK and able to be re-signed correctly. Possibly, nothing to do with Carthage.

NOTE: There is a similar problem iOS 8+ framework with nested embedded framework, however, mine has slightly other reason.

like image 464
Yevhen Dubinin Avatar asked Jul 22 '16 13:07

Yevhen Dubinin


2 Answers

The issue has nothing to dow with nested frameworks. It is entirely about codesignature validation. dyld is reporting that Other.framework is missing a codesignature. You need to sign the framework. This should be done for you by Xcode, so I'm curious how Other.framework is getting built.

You can probably work around this yourself by just signing it.

codesign --force --deep --preserve-metadata=identifier,entitlements,resource-rules,requirements,flags,team-identifier --sign - /path/to/Other.framework

or to just deeply resign your app:

codesign --force --deep --preserve-metadata=identifier,entitlements,resource-rules,requirements,flags,team-identifier --sign - /path/to/My.app
like image 52
Jeremy Huddleston Sequoia Avatar answered Oct 12 '22 08:10

Jeremy Huddleston Sequoia


I fixed my exact problem by following this guidance
You don't need to link your 'Other.framework' to your MyApp. Just add run script to sign the whatever embed framework that required code signature missing

like image 2
steveluoxin Avatar answered Oct 12 '22 09:10

steveluoxin