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

你可能感兴趣的:(iOS M1芯片Mac上Xcode模拟器报错解决)