I am trying to archive an app and prepare it for distribution in the App Store. During the validation of the archive (which can be triggered from XCode's Organizer) the following error pops up:
From what I can tell some of my frameworks which contain nested frameworks cannot be codesigned. If I remove all frameworks which contain nested frameworks then it starts working again.
As an example the following framework causes such an error:
Frameworks are build using Carthage
Here is the log output I am seeing:
2016-12-02 10:16:53 +0000 Processing step: IDEDistributionCodesignStep
2016-12-02 10:16:53 +0000 Applying entitlements delta for <IDEDistributionItem: 0x7fbc6f6e2a00 'com.hearst.ObjectMapper' '<DVTFilePath:0x7fbc530bde70:'/Users/gruener/Library/Developer/Xcode/Archives/2016-12-02/TestSubmitApp 02-12-16 11.16.xcarchive/Products/Applications/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework'>'> from <IDEiCloudEntitlementsProcessor: 0x7fbc6e036e70>: {
}
2016-12-02 10:16:53 +0000 Combining entitlements for <DVTFilePath:0x7fbc525ceb00:'/var/folders/3r/_6fw2smn4vj099_d7j2jtt0cg18svh/T/XcodeDistPipeline.bXb/Root/Payload/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework'>
bundleIdentifier = com.hearst.ObjectMapper
profileEntitlements = {
}
storedEntitlements = {
}
extraEntitlements = {
}
2016-12-02 10:16:53 +0000 Entitlements for <IDEDistributionItem: 0x7fbc6f6e2a00 'com.hearst.ObjectMapper' '<DVTFilePath:0x7fbc530bde70:'/Users/gruener/Library/Developer/Xcode/Archives/2016-12-02/TestSubmitApp 02-12-16 11.16.xcarchive/Products/Applications/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework'>'>: {
}
2016-12-02 10:16:53 +0000 Writing entitlements for <IDEDistributionItem: 0x7fbc6f6e2a00 'com.hearst.ObjectMapper' '<DVTFilePath:0x7fbc530bde70:'/Users/gruener/Library/Developer/Xcode/Archives/2016-12-02/TestSubmitApp 02-12-16 11.16.xcarchive/Products/Applications/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework'>'> to: /var/folders/3r/_6fw2smn4vj099_d7j2jtt0cg18svh/T/XcodeDistPipeline.bXb/entitlementsuaGdWl
2016-12-02 10:16:53 +0000 Running /usr/bin/codesign '-vvv' '--force' '--sign' 'A54D9A9C895E402713C0528523674342C777C825' '--preserve-metadata=identifier,resource-rules' '--entitlements' '/var/folders/3r/_6fw2smn4vj099_d7j2jtt0cg18svh/T/XcodeDistPipeline.bXb/entitlementsuaGdWl' '/var/folders/3r/_6fw2smn4vj099_d7j2jtt0cg18svh/T/XcodeDistPipeline.bXb/Root/Payload/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework'
2016-12-02 10:16:53 +0000 Warning: usage of --preserve-metadata with option "resource-rules" (deprecated in Mac OS X >= 10.10)!
2016-12-02 10:16:53 +0000 /var/folders/3r/_6fw2smn4vj099_d7j2jtt0cg18svh/T/XcodeDistPipeline.bXb/Root/Payload/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework: replacing existing signature
2016-12-02 10:16:53 +0000 /var/folders/3r/_6fw2smn4vj099_d7j2jtt0cg18svh/T/XcodeDistPipeline.bXb/Root/Payload/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework: invalid resource directory (directory or signature have been modified)
2016-12-02 10:16:53 +0000 /usr/bin/codesign exited with 1
I also tried building the IPA file with Fastlane's GYM. In this it works, however when I try to submit the App I receive this error:
WARNING ITMS-90686: "The binary you uploaded was invalid. (1102)"
Googling the error code 1102 yielded no results;
I finally figured out what the problem was.
I ran lipo info /path/to/Dto.framework/Dto
in a terminal and everything seemed fine - unnecessary architectures were correctly stripped away. But taking a closer look at the nested frameworks I realized that this was not the case for them.
Instead I found out that when working with Carthage you have to link all frameworks at app level and must not encapsulate them in your own frameworks.
So to solve this I removed the Copy files Phase
(which copies all frameworks to the frameworks directory). Carthage is smart enough to recognize this and also checks out the nested dependencies and builds them for you. The only thing you have to do then, is to add it to your Link Libraries Build Phase in XCode.