Mac M1芯片导致pod库找不到的问题
2022-02-06 本文已影响0人
独孤流
前言
因为使用需要,更换了一台M1芯片的mac电脑,在安装好各种pod、git、xcode环境后,其他项目在两台mac上都能运行模拟器,而另一个项目在intel芯片的mac电脑能正常在模拟器上运行,而在M1芯片上就会报错
ld: library not found for -lPod-xxx
, 查找了很多文章都没解决,然后使用真机运行就能完整运行,再查找文章发现就是M1芯片导致,需要在podfile里更新一下配置
发现某些pod会导致这个问题,比如: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
如下图
截屏2022-02-05 下午11.40.01.png
参考:https://narlei.com/development/apple-m1-xcode-error-when-build-in-simulator/