M1芯片的Mac无法在模拟器上运行项目building for iOS Simulator或could not find module for target..

5,929 阅读1分钟

本文是由Hilax同学提供的完美有效的解决方案,我只是稍作整理。

真机上可运行,模拟器上不行,并出现以下错误:

in xx/xx/arm64, building for iOS Simulator, but linking in object file built for iOS, file 'xx/xx'

could not find module for target 'x86_64-apple-ios-simulator'

image.png

解决方案

1.在项目的podfile的最后添加以下代码:

arduino
复制代码
post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end

如图:

2.回终端pod install一下

注:之后如需在真机上运行则需把上面第一步恢复原状,然后pod install一下。

(在上架App Store前也需这样做)