13

Framework in another framework in terms of code signing

solve a framework-in-framework code signing issues

Framework in another framework in terms of code signing

If your framework uses other framework, and when you build app that uses your framework, you would encounter code sign missing issue:

dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire
  Referenced from: /private/var/containers/Bundle/Application/56EAF4CD-0F82-4E41-ACE3-60F9B1C7C9B8/DistributedScrapyDemo.app/Frameworks/DistributedScrapy.framework/DistributedScrapy
  Reason: no suitable image found.  Did find:
	/private/var/containers/Bundle/Application/56EAF4CD-0F82-4E41-ACE3-60F9B1C7C9B8/DistributedScrapyDemo.app/Frameworks/DistributedScrapy.framework/Frameworks/Alamofire.framework/Alamofire: required code signature missing for '/private/var/containers/Bundle/Application/56EAF4CD-0F82-4E41-ACE3-60F9B1C7C9B8/DistributedScrapyDemo.app/Frameworks/DistributedScrapy.framework/Frameworks/Alamofire.framework/Alamofire'

Use below script if encounter code sign missing issue for the framework embedded in your framework in app target:

for f in $(find $CODESIGNING_FOLDER_PATH -name '*.framework')
do
echo "$f"
codesign --force --sign "iPhone Developer: XXX" --preserve-metadata=identifier,entitlements --timestamp=none "$f"
done

note "iPhone Developer: XXX" can be "${CODE_SIGN_IDENTITY}

The problem is, Xcode does not support nested frameworks. There are discussions here: [https://github.com/Carthage/Carthage/issues/1401] and [https://developer.apple.com/library/content/technotes/tn2435/_index.html] It’s said if framework B depends on framework C, you have to link C to B, and embed C into the app. Above script just recursively sign each framework, it’s kind of equivalent to include C into the app target. Because you have to add that run script in your app target. You can just touch nothing on app building.