前言
因為使用需要,更換了一臺M1芯片的mac電腦瘦馍,在安裝好各種pod应役、git情组、xcode環(huán)境后院崇,其他項目在兩臺mac上都能運行模擬器蕉陋,而另一個項目在intel芯片的mac電腦能正常在模擬器上運行,而在M1芯片上就會報錯
ld: library not found for -lPod-xxx
, 查找了很多文章都沒解決垦梆,然后使用真機運行就能完整運行托猩,再查找文章發(fā)現(xiàn)就是M1芯片導(dǎo)致鼻百,需要在podfile里更新一下配置
發(fā)現(xiàn)某些pod會導(dǎo)致這個問題摆尝,比如:pod 'Firebase/Analytics', '~>6.7.0'
步驟一勺爱,在podfile文件里配置如下
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
步驟二,注釋掉podfile里的use_frameworks!
完整多targe的demo如下:
platform :ios, '12.0'
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
targetsArray = ['aaa', 'bbb', 'ccc']
targetsArray.each do |t|
target t do
pod 'AFNetworking'
pod 'SDWebImage'
pod 'Firebase/Analytics', '~>6.7.0'
....
end
end
完整單targe的demo如下:
platform :ios, '12.0'
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
target 'Hello' do
# use_frameworks!
# Pods for Hello
pod 'AFNetworking'
pod 'Firebase/Analytics', '~>6.7.0'
target 'HelloTests' do
inherit! :search_paths
# Pods for testing
end
target 'HelloUITests' do
# Pods for testing
end
end
步驟三,Build Settings
->Architectures
->Excluded Architectures
-> Debug
->Any SDK
->arm64
如下圖
參考:https://narlei.com/development/apple-m1-xcode-error-when-build-in-simulator/