Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 373
pzs7602 Avatar asked Oct 12 '15 08:10

pzs7602


4 Answers

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

like image 167
Cosyn Avatar answered Oct 18 '22 07:10

Cosyn


I don't know why but somehow pods appeared to become an embedded binary. So I had to remove it, pod install once more, and the issue disappeared.

enter image description here

On Xcode 11 you need to change it to Do Not Embed in the Frameworks, Libraries, and Embedded Content.

like image 22
Jorge Casariego Avatar answered Oct 18 '22 07:10

Jorge Casariego


Double check Build Phases -> Copy Bundle Resources for a framework or other binary that shoundn't be there.

In my case, it was a 3rd party library (Parse) that I had added.

like image 23
a. brooks hollar Avatar answered Oct 18 '22 06:10

a. brooks hollar


In my case, I have a framework manually dragged into my project, and it is listed in General->Embedded Binaries, which cause error Found an unexpected Mach-O header code: 0x72613c21. After i moved it from Embedded Binaries to Linked Frameworks and Libraries, problem solved.

like image 23
Ke Yang Avatar answered Oct 18 '22 08:10

Ke Yang