解決方法:spec 文件移除指定cpu ,否則校驗(yàn)報(bào)錯(cuò),好像是xcode
spec.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
spec.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
1.錯(cuò)誤
xcode12更新之后,如果私有庫引入了第三方庫,pod repo push時(shí)會出現(xiàn)以下錯(cuò)誤:
ld: building for iOS Simulator, but linking in dylib built for iOS, file ' XXX ' for architecture arm64
clang: error: linker command failed with exit code 1
2.原因
這是因?yàn)樾聏code為了適配即將發(fā)布arm架構(gòu)芯片mac,會在編譯的時(shí)嘗試生成模擬器版本的arm64架構(gòu)的可執(zhí)行文件。然而引入的第三方SDK還沒來得及更新,老版本的第三方SDK并不包含模擬器版本的arm64架構(gòu)可執(zhí)行文件,所以在鏈接的時(shí)候就會失敗,上面的錯(cuò)誤提示也能看出端倪。簡單來說就以下兩個(gè)原因:
1.新xcode要生成模擬器版本的arm64架構(gòu)可執(zhí)行文件
2.引入的第三方sdk并沒有更新,不存在模擬器版本的arm64架構(gòu)可執(zhí)行文件
3.解決方案:
解決方法分一下幾種情況:
1.使用第三方SDK生成動態(tài)動態(tài)庫:
這種情況出現(xiàn)在swift項(xiàng)目中,為了解決第三方靜態(tài)庫在組件化中出現(xiàn)傳遞依賴等問題,把第三方SDK的靜態(tài)庫編譯成一個(gè)動態(tài)庫,制作方案可以參考組件化-動態(tài)庫實(shí)戰(zhàn),這里就不做詳細(xì)介紹了。這種情況需要在項(xiàng)目的target -> BuildSettings->EXCLUDED_ARCHS添加剔除模擬器arm64架構(gòu)配置:

image
2.普通私有庫pod repo push時(shí)報(bào)錯(cuò):
這種情況需要在podesc文件添加一下代碼:
s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
3. 如果項(xiàng)目使用了cocoapods需要在項(xiàng)目的Podfile里面添加代碼段,然后執(zhí)行pod install
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end