我有一个使用ObjC动态框架的Swift项目,该框架必须与我的项目链接并嵌入到我的项目中。该项目在设备中运行正常,提交给App Store时,验证期间发生错误:Found an unexpected Mach-O header code: 0x72613c21
以下是验证日志:

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

如果我从项目的“嵌入式框架”部分中删除了动态框架,那么它可以通过验证,但是由于缺少动态框架的图像而在设备中运行时崩溃了,你知道吗?
顺便说一句,动态框架已禁用了位码,因此我的项目也禁用了位码,并且未进行代码签名。

最佳答案

检查每个框架的两件事:

  • 框架的Mach-O类型(在框架目标的Build Settings中)

  • validation - 在Xcode 7中发现了意外的Mach-O header 代码:0x72613c21-LMLPHP
  • 是否通过在构建阶段->嵌入框架(或a。brooks hollar提到的复制 bundle 资源)中复制框架来复制它

    validation - 在Xcode 7中发现了意外的Mach-O header 代码:0x72613c21-LMLPHP

    如果框架的Mach-O类型是“静态库”,则不应将其放在嵌入框架中;如果Mach-O类型是“动态库”,则应将其放在嵌入框架中。

    在我的情况下,这是我手动添加的SocketRocket,它具有相同的框架名称的静态库目标和动态库目标。删除静态库目标并仅嵌入动态库框架之后,问题消失了。

    注意:

    如果您无权访问源项目,则可以使用以下方法手动检查它是动态框架还是静态框架:https://stackoverflow.com/a/32591983/308315

    关于validation - 在Xcode 7中发现了意外的Mach-O header 代码:0x72613c21,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33076819/

  • 10-09 15:52