Could not find module 'XXXX' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator 的错误一般出现在M系列芯片的Mac上。
解决方法:
方法一、在 TARGETS → Build Settings → Architectures → Excluded Architectures下添加arm64
示例.png
方法二、在Podfild文件中,添加如下内容:
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
end
end
end
end
添加后重新执行 pod install
方法三、(通用方案)M芯片电脑Xcode模拟器使用Rosetta
运行解决方案(这种模式是将arm64指令转成intel芯片的x86_64指令集,性能上会差一点)
Rosetta模式开启方法:打开 Product → Destination → Show All Run Destinations
示例.png
打开后在模拟器设备列表中会出现带有(Rosetta)标识的设备,选择并运行就可以了
开启Rosetta.png
以上方法一、二配置xcode 模拟器执行架构模式改为arm64的方案
,并不能完全解决所有问题,比如项目中如果使用了某个静态库,而该静态库打包模拟器的时候并没有支持arm64架构,那还是会编译不通过。虽说使用arm64运行模拟器会充分发挥M1芯片的优化,性能更高点,但一些老的三方库不支持也会导致整个项目跑不起来。
另一个缺点就是你修改之后提交了代码,其他同时使用intel芯片Mac的还是无法使用arm64架构的模拟器运行,所以这块代码不能提交以免影响其他同事。