Found an unexpected Mach-O header code: 0x72613c21 in Xcode 7

pzs7602 picture pzs7602 · Oct 12, 2015 · Viewed 38.7k times · Source

I have a Swift project that uses a ObjC dynamic framework, the framework had to be linked with and embedded into my project. The project runs OK in devices, when submitted to App Store, the error occurred during validation: Found an unexpected Mach-O header code: 0x72613c21

Below are the validation logs:

2015-10-12 02:32:33 +0000 [MT] Beginning distribution assistant for archive: MusicFans, task: Validate
2015-10-12 02:32:33 +0000 [MT] Automatically selecting the only availaable distribution method <IDEDistributionMethodiOSAppStoreValidation: 0x7f851c1d96c0>
2015-10-12 02:32:34 +0000 [MT] [OPTIONAL] Didn't find archived user entitlements for <DVTFilePath:0x7f851b42db10:'/Users/panzhansheng/Library/Developer/Xcode/Archives/2015-10-11/MusicFans 11-10-15 上午8.29.xcarchive/Products/Applications/MusicFans.app/Frameworks/libswiftDispatch.dylib'>: Error Domain=NSCocoaErrorDomain Code=4 "Item at "/Users/panzhansheng/Library/Developer/Xcode/Archives/2015-10-11/MusicFans 11-10-15 上午8.29.xcarchive/Products/Applications/MusicFans.app/Frameworks/libswiftDispatch.dylib" did not contain a "archived-expanded-entitlements.xcent" resource." UserInfo={NSLocalizedDescription=Item at "/Users/panzhansheng/Library/Developer/Xcode/Archives/2015-10-11/MusicFans 11-10-15 上午8.29.xcarchive/Products/Applications/MusicFans.app/Frameworks/libswiftDispatch.dylib" did not contain a "archived-expanded-entitlements.xcent" resource.}
2015-10-12 02:32:34 +0000 [MT] [OPTIONAL] Didn't find archived user entitlements for <DVTFilePath:0x7f8529a08050:'/Users/panzhansheng/Library/Developer/Xcode/Archives/2015-10-11/MusicFans 11-10-15 上午8.29.xcarchive/Products/Applications/MusicFans.app/wavpack.framework'>: Error Domain=NSCocoaErrorDomain Code=4 "Item at "/Users/panzhansheng/Library/Developer/Xcode/Archives/2015-10-11/MusicFans 11-10-15 上午8.29.xcarchive/Products/Applications/MusicFans.app/wavpack.framework" did not contain a "archived-expanded-entitlements.xcent" resource." UserInfo={NSLocalizedDescription=Item at "/Users/panzhansheng/Library/Developer/Xcode/Archives/2015-10-11/MusicFans 11-10-15 上午8.29.xcarchive/Products/Applications/MusicFans.app/wavpack.framework" did not contain a "archived-expanded-entitlements.xcent" resource.}
2015-10-12 02:32:34 +0000 [MT] [OPTIONAL] Didn't find archived user entitlements for <DVTFilePath:0x7f850da13de0:'/Users/panzhansheng/Library/Developer/Xcode/Archives/2015-10-11/MusicFans 11-10-15 上午8.29.xcarchive/Products/Applications/MusicFans.app/FLAC.framework'>: Error Domain=NSCocoaErrorDomain Code=4 "Item at "/Users/panzhansheng/Library/Developer/Xcode/Archives/2015-10-11/MusicFans 11-10-15 上午8.29.xcarchive/Products/Applications/MusicFans.app/FLAC.framework" did not contain a "archived-expanded-entitlements.xcent" resource." UserInfo={NSLocalizedDescription=Item at "/Users/panzhansheng/Library/Developer/Xcode/Archives/2015-10-11/MusicFans 11-10-15 上午8.29.xcarchive/Products/Applications/MusicFans.app/FLAC.framework" did not contain a "archived-expanded-entitlements.xcent" resource.}
2015-10-12 02:33:07 +0000 [MT] Canceled distribution assistant

If I remove the dynamic framework from the project’s Embedded frameworks section, then it can pass the validation, but crashes when run in devices due to the missing image of my dynamic framework, any idea? BTW, dynamic framework has bitcode disabled, so my project also disables bitcode, and is not codesigned.

Answer

Cosyn picture Cosyn · Feb 14, 2017

Check two things for every framework:

  1. The Mach-O type of the framework (in Build Settings of the framework target)

Mach-O

  1. Whether you copy the framework by putting it in Build Phases -> Embed Frameworks (or Copy Bundle Resources as mentioned by a. brooks hollar)

Embed frameworks

If the Mach-O type of the framework is "static library", it should not be put in embed frameworks; if the Mach-O type is "dynamic library", it should be put in embed frameworks.

In my case it was SocketRocket I added manually which has both a static library target and a dynamic library target with the same framework name. After deleting the static library target and only embed the dynamic library framework, the problem disappears.


Note:

If you don't have access to the source project, you can manually check if it's a dynamic or static framework using this approach: https://stackoverflow.com/a/32591983/308315