iOS M1芯片Mac上Xcode模拟器报错解决

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

..., building for iOS Simulator, but linking in object file built for iOS, file '...'

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

解决方案一

1.添加arm64到项目PEROJECTTARGETSExcluded Architectures

路径1:PEROJECT - Build Settings - Excluded Architectures
路径2:TARGETS - Build Settings - Excluded Architectures
如图:

1660035346960.jpg

2.在项目的podfile的最后添加以下代码
post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end
3.clean项目,最后终端pod install下,重新运行项目就能在模拟器运行了

注意:之后如需在真机上运行则需把上面第一步和第二步恢复原状,然后pod install一下。(在上架App Store前也需这样做)

解决方案二

1660035987092.jpg
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容