简体   繁体   English

为什么我的 M1 Mac 上的 Xcode 试图为 `iOS Simulator-x86_64` 构建? 为什么它不是为基于“arm”的模拟器构建的?

[英]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.我现在可以安心睡觉了。

You can try opening Xcode with "Open using Rosetta" check ON.您可以尝试打开 Xcode 并勾选“使用 Rosetta 打开”。

  1. Quit Xcode退出 Xcode
  2. Go to your Applications folder转到您的应用程序文件夹
  3. Right click Xcode then select "Get Info"右键单击 Xcode,然后选择“获取信息”
  4. Check "Open using Rosetta"勾选“使用 Rosetta 打开”
  5. Open Xcode打开 Xcode

使用 Rosetta 打开

如果您有一个不支持 arm64 的依赖项,您可以通过将“arm64”添加到目标构建设置中的排除架构列表 ( EXCLUDED_ARCHS ) 中来告诉构建系统跳过 arm64(此构建 x86_64)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Xcode 12 问题 - 找不到目标“arm64-apple-ios-simulator”的模块“FrameworkName”; 找到:x86_64-apple-ios-simulator,x86_64 - Xcode 12 issue - Could not find module 'FrameworkName' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, x86_64 Xcode 12 Mac M1 和 Cocoapods:我可以在模拟器上构建,但不能在设备上构建 - Xcode 12 Mac M1 with Cocoapods: I can build on simulator but not on device 找不到目标“arm64-apple-ios-simulator”的模块“Alamofire”; 找到:x86_64-apple-ios-simulator,x86_64 - could not find module 'Alamofire' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, x86_64 找不到目标“x86_64-apple-ios-simulator”的模块“FBSDKCoreKit”; 找到:arm64,arm64-apple-ios-simulator - Could not find module 'FBSDKCoreKit' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator 找不到目标“x86_64-apple-ios-simulator”的模块“XXXX”; 在 Swift 项目中找到:arm64、arm64-apple-ios-simulator? - Could not find module 'XXXX' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator in Swift Project? 找不到目标“x86_64-apple-ios-simulator”的模块“MyCustomFramework”; 找到:arm64、armv7-apple-ios、arm64-apple-ios、arm、armv7 - Could not find module 'MyCustomFramework' for target 'x86_64-apple-ios-simulator'; found: arm64, armv7-apple-ios, arm64-apple-ios, arm, armv7 为什么我的应用程序不能安装在模拟器或设备上 iOS xcode - Why won't my application install on simulator or device iOS xcode 无法在此处为 ios-arm64-simulator 构建 SDK Premium - Unable to build HERE SDK Premium for ios-arm64-simulator 为 iOS 模拟器构建,但在为 iOS 构建的 object 文件中链接,架构 arm64 的文件“.../GoogleMaps” - building for iOS Simulator, but linking in object file built for iOS, file '.../GoogleMaps' for architecture arm64 Swift | GoogleSignIn pod:为 iOS 模拟器构建,但在为架构 arm64 的 iOS 文件构建的 object 文件中链接 - Swift | GoogleSignIn pod: building for iOS Simulator, but linking in object file built for iOS file for architecture arm64
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM