简体   繁体   English

架构 arm64 的未定义符号:Xcode 12

[英]Undefined symbols for architecture arm64: Xcode 12

Im trying to build a project after adding 3rd party framework, however I can't compile the project after adding the framework, I get Undefined symbols for architecture arm64 : error when I try to compile on a device, but I can compile on a simulator.我在添加 3rd 方框架后尝试构建一个项目,但是在添加框架后我无法编译该项目,我收到架构 arm64 的未定义符号:尝试在设备上编译时出错,但我可以在模拟器上编译. I have tried all other solutions I found on stackoverflow.我已经尝试了在 stackoverflow 上找到的所有其他解决方案。 any help is appreciated!任何帮助表示赞赏!

Here is what I have tried:这是我尝试过的:

  • Added Any iOS Simulator SDK with value arm64 inside Excluded Architecture.在排除架构中添加了值为arm64 的Any iOS Simulator SDK。
  • I do have $(inherited) inside Other Linker Flags我确实在其他链接器标志中有 $(inherited)
  • Set Bitcode Enabled to No将启用位码设置为否

None of the solutions I tried worked for me.我尝试过的所有解决方案都不适合我。

Undefined symbols for architecture arm64:
      "_OBJC_CLASS_$_*", referenced from:
          objc-class-ref in frameworkName.o
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
  1. "Product" -> "Scheme" -> "Edit Scheme" “产品”->“方案”->“编辑方案”
  2. select "Build"选择“构建”
  3. Uncheck "Parallelize Build"取消选中“并行构建”

Try adding this to your pod file尝试将其添加到您的 pod 文件中

post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
          end
        end
    end

I found the issue.我发现了这个问题。

My project supports lower minimum deployment target than the framework, and that caused the issue.我的项目支持比框架更低的最低部署目标,这导致了问题。 I had to include the framework starting from a specific iOS version.我必须包含从特定 iOS 版本开始的框架。

Here is the scenario and the issue: my project supports iOS 9 and the framework supports starting from 9.1.这是场景和问题:我的项目支持 iOS 9,框架支持从 9.1 开始。 For that reason I was not getting the latest framework, instead Cocoapods was downloading the older version of the framework which doesn't support arm64.出于这个原因,我没有得到最新的框架,而是 Cocoapods 下载了不支持 arm64 的旧版本框架。

So for the time being I just included the framework only for iOS 9.1 and above:所以暂时我只包含了仅适用于 iOS 9.1 及更高版本的框架:

platform :ios, '9.1'
      pod 'PodName', '~> 3.2'

Then the project compiled properly, thanks for those who tried to help.然后项目编译正确,感谢那些试图提供帮助的人。 I spent half day because of this and Im putting this here for anyone who might face the same problem.为此我花了半天时间,我把它放在这里,供任何可能面临同样问题的人使用。

There are many possible reasons, last armv7 version stays in iOS 10. So for me:有很多可能的原因,最后一个 armv7 版本停留在 iOS 10 中。所以对我来说:

I tried to use "Valid Architectures" without 'armv7', which doesn't exist in Xcode 12 anymore.我尝试使用没有“armv7”的“有效架构”,它在 Xcode 12 中不再存在。

Next I tried ONLY_ACTIVE_ARCH, which I know this will result in I cannot Archive my app in the end接下来我尝试了 ONLY_ACTIVE_ARCH,我知道这会导致我最终无法存档我的应​​用程序

Finally, I searched my local podspec, found最后,我搜索了我本地的 podspec,发现

    s.ios.deployment_target = "10.0"

Since my main app's minimum deploy target is set to iOS 11. So I set由于我的主应用程序的最小部署目标设置为 iOS 11。所以我设置

    s.ios.deployment_target = "11.0"

Xcode doesn't complain this armv7 anymore. Xcode 不再抱怨这个 armv7。

Hope this will help someone, check your framework or any dependencies, make sure they are set correctly.希望这会对某人有所帮助,检查您的框架或任何依赖项,确保它们设置正确。

I found it help to set the target membership of file that has this error to target.我发现将具有此错误的文件的目标成员资格设置为目标会有所帮助。 click on a file that produced this error, on the right of Xcode there is the inspector.单击产生此错误的文件,Xcode 右侧有检查器。 in inspector It shows target membership.在检查器中显示目标成员资格。 if file is currently not of any target membership select what you want.如果文件当前不属于任何目标成员,请选择您想要的。

Forget about complicated answers that can affect other developed apps because you change XCODE inners.忘记可能会影响其他开发的应用程序的复杂答案,因为您更改了 XCODE 内部结构。

In my experience, this happens because you update versions duplicating projects, that it is the simplest way to do it.根据我的经验,发生这种情况是因为您更新版本复制项目,这是最简单的方法。

The problem is worked out when you set to YES the "Enable Modules (C and Objetive -C)" parameter in BUILD SETTINGS tab.当您将 BUILD SETTINGS 选项卡中的“启用模块(C 和 Objetive -C)”参数设置为 YES 时,问题就解决了。

I also recommend to compare the BUILD SETTINGS parameters (there are a lot but is faster than rebuild the project ... I do not understand why Apple makes it so complicated) beetween projects than work ok.我还建议在项目之间比较 BUILD SETTINGS 参数(有很多但比重建项目更快......我不明白为什么 Apple 让它如此复杂)比工作正常。

BUILD SETTINGS 参数比较

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM