公司的一个老项目,在MacMini上build失败,要求升级Xcode,于是升级了Xcode,之后如我所想,报错。在MacMini上远程折腾了好几个小时,不过没想到最后是在m1上解决了。
下面记录2个错误和解决(还是要会用搜索引擎)。
错误一:
/Users/a123/Library/Developer/Xcode/DerivedData/StoreApp-fwwfjzkqlgwsvgdugbsmhbnfwwhu/Build/Products/Release-iphoneos/AFNetworking-iOS11.0/AFNetworking.framework/AFNetworking' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/Users/a123/Library/Developer/Xcode/DerivedData/StoreApp-fwwfjzkqlgwsvgdugbsmhbnfwwhu/Build/Products/Release-iphoneos/AFNetworking-iOS11.0/AFNetworking.framework/AFNetworking' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation
错误解释:AFNetworking这个做网络请求不支持bitcode,提示让这个库开启bitcode,或者在target里关闭bitcode。
查资料得知Xcode14中放弃了bitcode,iOS 9、iOS 10,最小支持iOS 11,所以:
第一步:设置iOS Development Target
: 11.0
第二步:
尝试一,升级AFNetworking,使用支持bitcode的库。
很遗憾,AFNetworking最新版本4.0.1与,我们项目里使用的4.0一样,此路不通。
尝试二,按照提示关闭bitcode
具体在target --> Built Seeting -->搜索 ENABLE_BITCODE --->将Yes置为No。
bitcode结论
尝试二成功。
下面的方式应该更加推荐,但是我尝试没有成功,理论上肯定能成功的,只是没有再试。
还是按照上面的关闭,只是在Podfile中修改
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
end
end
end
错误二:
rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/810eba08-405a-11ed-86e9-6af958a02716/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]
Command PhaseScriptExecution failed with a nonzero exit code
解决方法
在Xcode项目目录中进入 Pods -> Targets Support Files -> Pods-项目名 -> Pods-项目名-frameworks.sh 中搜索source="$(readlink "${source}")"
,找到后将其替换为source="$(readlink -f "${source}")"
,然后重新进行打包操作。
这貌似是Cocoapods的问题😭。
参考链接
AFNetworking was built without full bitcode
Xcode14 正式版编译报错‘ does not contain bitcode.解决方案
升级Xcode14.3后打包报错Command PhaseScriptExecution failed with a nonzero exit code
网友评论