Xcode12孵延,13,14 在使用模擬器(Simulator)時(shí)編譯錯(cuò)誤的解決方法
就是說(shuō)在真機(jī)上可以運(yùn)行 模擬器上運(yùn)行失敗報(bào)出:?for architecture arm64
Showing All Messages
In /Users/mac/Desktop/adancing/eredar/eredar/Pods/APBToygerFacade/APBToygerFacade.framework/APBToygerFacade(APBToygerGuideTask.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/mac/Desktop/adancing/eredar/eredar/Pods/APBToygerFacade/APBToygerFacade.framework/APBToygerFacade' for architecture arm64
Showing All Messages
Linker command failed with exit code 1 (use -v to see invocation)
解決方法:
1、Xcode11 項(xiàng)目中模擬器會(huì)編譯為x86_64上忍,但Xcode12的模擬器基于蘋(píng)果Apple Silicon architecture執(zhí)行庐完,需要編譯為arm64運(yùn)行在模擬器上爪模。許多第三方庫(kù)(如Firebase址遇,AFNetworking等)并未提供Xcode12版本的更新支持队寇,導(dǎo)致報(bào)錯(cuò)吩屹。
2啸驯、Xcode12 開(kāi)始移除編譯設(shè)置(Bulid Settings)中的 Valid Architectures的宏定義。當(dāng)項(xiàng)目使用Xcode12打開(kāi)時(shí)候祟峦,會(huì)在User-Defines(項(xiàng)目的Bulid Settings里面)中自動(dòng)生成VALID_ARCHS宏定義罚斗。如果舊項(xiàng)目存在于此沖突的宏定義,會(huì)導(dǎo)致編譯失敗宅楞。
如何修復(fù)针姿?
第一步:添加 arm64 到 simulator architecture 中。主項(xiàng)目和pod項(xiàng)目都需要厌衙。
在主項(xiàng)目和pod項(xiàng)目的PROJECT的Build Settings中距淫,搜索Excluded Architecture ,添加 Any iOS Simulator SDK婶希,value填入 arm64
注意:在pod項(xiàng)目的build setting是cocopod自動(dòng)生成的榕暇,本次修改在下次更新第三方庫(kù)時(shí)候會(huì)被覆蓋,可以添加腳本在Podfile中喻杈,防止每次安裝和更新都需要手動(dòng)修改彤枢。
post_install do |installer|
? installer.pods_project.build_configurations.each do |config|
? ? config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
? end
end
第二步:在主項(xiàng)目和pod項(xiàng)目的PROJECT的Build Settings中,刪除VALID_ARCHS(整個(gè)刪除筒饰,不能只刪除value留下Key)
————————————————
可以參考這里:
原文鏈接:https://blog.csdn.net/babylv1/article/details/109395657