gpt4 book ai didi

ios - Xcode12 - 为 iOS 模拟器构建,但链接为 macOS 构建的目标文件,文件 'dir/SomeFile.a' 用于架构 x86_64

转载 作者:行者123 更新时间:2023-12-03 11:16:10 27 4
gpt4 key购买 nike

Xcode 12 中出现链接器错误当我尝试构建大型 iOS 应用程序(混合、swift+objc)时。该应用程序在真实设备上构建得很好,但是当我尝试使用调试配置直接在模拟器中运行时,它会出现链接器错误。
我在其他帖子中尝试了所有可能的解决方案 here ,但不幸的是它没有奏效。尽管其他帖子中的错误有所不同。我查了 Build for active architectures only调试配置为 YES,发布配置为 NO。
其他帖子错误,

building for iOS Simulator, but linking in object file built for iOS, for architecture arm64


我的错误,

building for iOS Simulator, but linking in object file built for macOS, file for architecture x86_64


我该如何解决这个问题? 我需要在 iOS 真机和模拟器中运行。

最佳答案

无论您从何处获得库,您都应该请求为 iOS 模拟器而不是 macOS 编译的库,尽管它们具有通过 lipo -info <file> 返回的相同二进制架构.
您可以使用以下命令验证您的静态 (.a) 或动态库 (.dylib) 是否为 iOS 模拟器编译:

otool -l <path-to-library> | grep platform
输出的含义如下:
  • platform 7 - iOS模拟器
  • platform 6 - Mac 催化剂
  • platform 4 - watchOS
  • platform 2 - iOS
  • platform 1 - macOS

  • Hereplatform 的枚举的完整定义.

    关于ios - Xcode12 - 为 iOS 模拟器构建,但链接为 macOS 构建的目标文件,文件 'dir/SomeFile.a' 用于架构 x86_64,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64152923/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com