xcode12 issus: ld :building for iOS Simulator,但链接到为 iOS 构建的目标文件,文件 'xxx.framework/xxx' 用于架构 arm64

bur*_*sun 6 xcode ios xcode12

升级xcode12后?build issus:

ld :building for iOS Simulator, but linking in object file built for iOS, file 'xxx.framework/xxx' for architecture arm64
Run Code Online (Sandbox Code Playgroud)

它可以在 iPhone 上运行

Avn*_*wal 14

构建设置编辑器不再包含有效架构构建设置“VALID ARCHS”,并且不鼓励使用它。相反,有一个新的 Excluded Architectures 构建设置(EXCLUDED ARCHS)

Xcode 12 实际上是 Apple Silicon 的垫脚石,不幸的是,它还没有推出。但是有了这个平台,我们将获得基于 arm64 的 macOS,其中模拟器也将在 arm64 架构上运行,这与目前基于 Intel 的 x86_64 架构不同。

Xcode 通常依赖于“运行目标”来构建它的库/应用程序。So when a simulator is chosen as the "Run Destination", it builds the app for available simulator architectures and when a device is chosen as the "Run Destination" it builds for the architecture that the device supports (arm*).

xcodebuild 在 Xcode 12+ 构建系统中,将 arm64 视为模拟器的有效架构。So when a simulator is chosen as the run destination, it can potentially try to compile/link your libs/apps against arm64 based simulators as well (not available yet). 因此,它以 --- 格式发送 clang(++) 一些 -target 标志,如 arm64-apple-ios13.0-simulator,并且 clang 尝试构建/链接基于 arm64 的模拟器,最终在基于 Intel 的 mac 上失败。

但是 xcodebuild 仅针对发布版本尝试此操作。为什么?因为,“仅构建活动架构(ONLY_ACTIVE_ARCH)”构建设置通常仅针对“发布”配置设置为“否”。这意味着 xcodebuild 将尝试为所选的发布版本运行目标构建库/应用程序的所有架构变体。对于模拟器运行目标,它现在将包括 x86_64 和 arm64,因为 Xcode 12+ 中的 arm64 也是模拟器支持 Apple Silicon 的支持架构。

简而言之,Xcode 将无法在任何时候尝试命令行 xcodebuild(默认为发布构建,请参阅项目设置的常规选项卡)或以其他方式在发布模式下构建您的应用程序。因此,解决此问题的一个简单方法是在您的库/应用程序中将“仅构建活动架构(ONLY_ACTIVE_ARCH)”设置为“是”,即使对于发布模式也是如此。

选择 Traget 然后转到构建设置

解决问题的步骤:

解决方案1:

  1. 选择项目目标
  2. 转到构建设置
  3. 全选
  4. 搜索“仅构建活动架构”
  5. 即使对于发布模式,仅将活动架构构建为“是”。
  6. 重新构建

解决方案2:

  1. 选择项目目标
  2. 转到构建设置
  3. 全选
  4. 搜索“排除的架构”
  5. 将“arm64”添加到“Any iOS Simulator SDK”选项的发布和调试模式。
  6. 重新构建

在此处输入图片说明