错误详情描述
ios打包时,"** ARCHIVE SUCCEEDED **"成功了,但是从"..xcarchive"文件导出"ipa"文件时(即xcodebuild -exportArchive
),却报错,如下:
xcodebuild[49559:8399880] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/zp/bhhpqy8x5l79szqgq4kk5h640000gn/T/OKEx_2019-01-11_20-34-38.381.xcdistributionlogs'.
2019-01-11 20:34:39.109 xcodebuild[49559:8399880] [MT] IDEDistribution: Failed to generate distribution items with error: Error Domain=DVTMachOErrorDomain Code=0 "Found an unexpected Mach-O header code: 0x72613c21" UserInfo={NSLocalizedDescription=Found an unexpected Mach-O header code: 0x72613c21, NSLocalizedRecoverySuggestion=}
error: exportArchive: Found an unexpected Mach-O header code: 0x72613c21
Error Domain=DVTMachOErrorDomain Code=0 "Found an unexpected Mach-O header code: 0x72613c21" UserInfo={NSLocalizedDescription=Found an unexpected Mach-O header code: 0x72613c21, NSLocalizedRecoverySuggestion=}
** EXPORT FAILED **
里面最关键的一句是:“error: exportArchive: Found an unexpected Mach-O header code: 0x72613c21”
网上其他的解决办法
网上有些说是因为 “Embedded Binaries”里包含了静态库,
解决办法:将 Embedded Binaries 中的静态库移到 Linked Frameworks and Libraries 中;
我的解决办法
我这并不是因为“Embedded Binaries”里包含了静态库;
我使用了cocoapods,我的资源目录里有一些bundle文件和静态framework文件,在“podspec”文件里设置“resource_bundles”字段时不小心使用了通配符,导致项目的 "target"-"Build Phases"-"Copy Bundle Resources"里加入了framework文件,最终把这个framework拷贝到了".app"里(也可能在.app的一些bundle文件内部),
在xcode正常的debug编译时不会出现问题,但是到打包发布时,问题就出现了:
第一步archive时,是正常的;
第二步export时,检测到.app里包含非常规的静态framework文件时,就会报上面的错误“error: exportArchive: Found an unexpected Mach-O header code: 0x72613c21”;
注意".app"目录下的“Frameworks”是可以包含动态framework的
**解决办法:**当然把"Copy Bundle Resources"里的framework去掉即可