[英]Why is Xcode on my M1 Mac trying to build for `iOS Simulator-x86_64`? Why is it not building for an `arm` based simulator?
I have an M1 MacBook Air.我有一台 M1 MacBook Air。
When building for a simulator in Xcode, I am seeing the following warnings and errors:在 Xcode 中构建模拟器时,我看到以下警告和错误:
ld: warning: ignoring file /Users/kon/Library/Developer/Xcode/DerivedData/InvisibleComputersApp-hktlnhvaoskvxkcdhnahydmbodzw/Build/Products/Debug-iphonesimulator/GoogleSignIn.o, building for iOS Simulator-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file /Users/kon/Library/Developer/Xcode/DerivedData/InvisibleComputersApp-hktlnhvaoskvxkcdhnahydmbodzw/Build/Products/Debug-iphonesimulator/AppAuth.o, building for iOS Simulator-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file
/Users/kon/Library/Developer/Xcode/DerivedData/InvisibleComputersApp-hktlnhvaoskvxkcdhnahydmbodzw/Build/Products/Debug-iphonesimulator/GTMAppAuth.o, building for iOS Simulator-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file /Users/kon/Library/Developer/Xcode/DerivedData/InvisibleComputersApp-hktlnhvaoskvxkcdhnahydmbodzw/Build/Products/Debug-iphonesimulator/AppAuthCore.o, building for iOS Simulator-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file /Users/kon/Library/Developer/Xcode/DerivedData/InvisibleComputersApp-hktlnhvaoskvxkcdhnahydmbodzw/Build/Products/Debug-iphonesimulator/GTMSessionFetcherCore.o, building for iOS Simulator-x86_64 but attempting to link with file built for unknown-arm64
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GIDConfiguration", referenced from:
objc-class-ref in GlobalState.o
"_OBJC_CLASS_$_GIDSignIn", referenced from:
objc-class-ref in GoogleAuthService.o
objc-class-ref in GoogleRefreshTokenService.o
objc-class-ref in InvisibleComputersAppApp.o
"_OBJC_CLASS_$_GIDSignInButton", referenced from:
objc-class-ref in LoginView.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This sounds to me like Xcode is somehow trying to build an x86 binary?这听起来像 Xcode 正在尝试构建一个 x86 二进制文件? Why is it even trying to do that, aren't the simulators arm
based on the M1 Macs?为什么它甚至试图这样做,不是基于 M1 Mac 的模拟器arm
吗?
How can I我怎么能够
I spent 3 days on this issue beating my head against the wall.我在这个问题上花了 3 天的时间,把头撞在墙上。 Today, I finally cracked it and understood the problem.今天终于破解了,明白了问题所在。
I am working on a highly modular project with ~100 frameworks.我正在从事一个具有约 100 个框架的高度模块化项目。 When migrating from the X86_64 (Intel) architecture to arm64 (M1) I was always getting this error:从 X86_64 (Intel) 架构迁移到 arm64 (M1) 时,我总是收到此错误:
Could not find module 'MyModule' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator, at /my/path/
when building natively on M1.在 M1 上本地构建时。
The reason is that the simulator runs natively on M1 but the simulated app runs still under Intel.原因是模拟器在 M1 上本机运行,但模拟应用程序仍在 Intel 下运行。 That's why the x86_64 architecture was built in the first place.这就是为什么首先构建 x86_64 架构的原因。
The two architectures are now beating each other as the simulator is arm64 while the simulated app is X86_64.这两种架构现在相互竞争,因为模拟器是 arm64,而模拟的应用程序是 X86_64。 Removing the arm64 architecture for the pods and project settings fixed the issue and I can build the project entirely on M1 now.删除 pod 的 arm64 架构和项目设置解决了这个问题,我现在可以完全在 M1 上构建项目。
Here are screenshots from the ActivityMonitor.以下是 ActivityMonitor 的屏幕截图。 AchieveMe is the app running in the simulator. AchieveMe 是在模拟器中运行的应用程序。
To fix the problem for Cocoapods you can simply do:要解决 Cocoapods 的问题,您只需执行以下操作:
target.build_configurations.each do |config|
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
end
I am using XcodeGen and there it can simply be added under debug configuration as:我正在使用 XcodeGen,它可以简单地添加到调试配置下:
YourSettings
...
configs:
Debug:
EXCLUDED_ARCHS[sdk=iphonesimulator*]: arm64
Best of luck, I hope it helps.祝你好运,希望对你有所帮助。 I can sleep in peace now.我现在可以安心睡觉了。
如果您有一个不支持 arm64 的依赖项,您可以通过将“arm64”添加到目标构建设置中的排除架构列表 ( EXCLUDED_ARCHS
) 中来告诉构建系统跳过 arm64(此构建 x86_64)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.