ios 架构 arm64 的未定义符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19213782/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:08:09  来源:igfitidea点击:

Undefined symbols for architecture arm64

iosxcodexcode5cocoapods

提问by GangstaGraham

I am getting a Apple Mach-O Linker Error everytime I import a file from CocoaPods.

每次从 CocoaPods 导入文件时,我都会收到 Apple Mach-O 链接器错误。

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_FBSession", referenced from: someFile
ld: symbol(s) not found for architecture arm64

I get about 12 of these, for the various Pods I use.

对于我使用的各种 Pod,我得到了大约 12 个。

I am trying to build for the iPhone 5S using XCode 5.

我正在尝试使用 XCode 5 为 iPhone 5S 构建。

I've been trying various solutions here on SO, but haven't got any of them to work yet.

我一直在 SO 上尝试各种解决方案,但还没有任何解决方案起作用。

How do I fix this Apple Mach-O Linker Error?

如何修复此 Apple Mach-O 链接器错误?



Just found another warning that might be interesting, I hope this leads me to the solution:

刚刚发现另一个可能有趣的警告,我希望这能引导我找到解决方案:

Ignoring file ~/Library/Developer/Xcode/DerivedData/SomeApp/Build/Products/Debug-iphoneos/libPods.a, 

file was built for archive which is not the architecture being linked(arm64):~/Library/Developer/Xcode/DerivedData/someApp/Build/Products/Debug-iphoneos/libPods.a

file was built for archive which is not the architecture being linked(arm64):~/Library/Developer/Xcode/DerivedData/someApp/Build/Products/Debug-iphoneos/libPods.a

回答by chancyWu

If your Architecturesand Valid Architecturesare all right, you may check whether you have added $(inherited), which will add linker flags generated in pods, to Other Linker Flagsas below: enter image description here

如果您的ArchitecturesValid Architectures都没有问题,您可以检查您是否添加了$(inherited),它将添加 pod 中生成的 链接器标志,如下所示: 在此处输入图片说明

回答by AdamG

The issue is that the cocoapods have not been built for arm64 architecture yet thus they cannot be linked when you build them. Likely you cannot use those packages until they are updated and use that architecture. You can fix the linker error by going to project -> target (your project name) -> build settings and change architectures to standard architectures (armv7, armv7s), and valid architectures to armv7, armv7s.

问题是 cocoapods 尚未针对 arm64 架构构建,因此在构建它们时无法链接它们。您可能无法使用这些包,直到它们更新并使用该架构。您可以通过转到项目 -> 目标(您的项目名称)-> 构建设置并将架构更改为标准架构(armv7、armv7s)并将有效架构更改为 armv7、armv7s 来修复链接器错误。

Note though, this means you won't get the full power of the 64 bit processor. You said you are building for the 5s, so there may be some reason you need this. If you for some reason absolutely need that power (perhaps you are building a game), and desperately need those files, you could submit a pull request and then recompile the project to arm64 by setting those same fields to arm64 in the files you pulled from the open source projects. But, unless you really need these files to be 64 bit compatible, that seems like a bit of overkill for now.

但请注意,这意味着您将无法获得 64 位处理器的全部功能。你说你是为 5s 构建的,所以可能有一些原因你需要这个。如果您出于某种原因绝对需要这种功能(也许您正在构建游戏),并且迫切需要这些文件,您可以提交拉取请求,然后通过在您拉取的文件中将这些相同的字段设置为 arm64 将项目重新编译为 arm64开源项目。但是,除非您真的需要这些文件兼容 64 位,否则现在这似乎有点矫枉过正。

EDIT: Some people also reported that setting Build For Active Architectures to YES was also necessary to solve this problem.

编辑:有些人还报告说,将 Build For Active Architectures 设置为 YES 也是解决此问题所必需的。

As of 2014-04-28 the setting should look something like this:

截至 2014-04-28,设置应如下所示:

enter image description here

在此处输入图片说明

回答by morisunshine

I solved this problem by setting that:

我通过设置解决了这个问题:

ARCHS = armv7 armv7s

ARCHS = armv7 armv7s

VALID_ARCHS = armv6 armv7 armv7s arm64

VALID_ARCHS = armv6 armv7 armv7s arm64

回答by valbu17

I ran into the same/similar issue implementing AVPictureInPictureControllerand the issue was that I wasn't linking the AVKitframework in my project.

我在实施时遇到了相同/类似的问题AVPictureInPictureController,问题是我没有在我的项目中链接AVKit框架。

The error message was:

错误消息是:

Undefined symbols for architecture armv7:
   "_OBJC_CLASS_$_AVPictureInPictureController", referenced from:
       objc-class-ref in yourTarget.a(yourObject.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The Solution:

解决方案:

  1. Go to your Project
  2. Select your Target
  3. Then, go to Build Phases
  4. Open Link Binary With Libraries
  5. Finally, just add +the AVKitframework/ any other framework.
  1. 转到您的项目
  2. 选择你的目标
  3. 然后,转到构建阶段
  4. 使用库打开链接二进制文件
  5. 最后,只需添加+AVKit框架/任何其他框架

Hopefully this helps someone else running into a similar issue I had.

希望这可以帮助其他人遇到我遇到的类似问题。

回答by ylgwhyh

I also encountered the same problem , the above methods will not work . I accidentally deleted the files in the following directory on it .

我也遇到了同样的问题,上面的方法都不行。我不小心删除了以下目录中的文件就可以了。

Folder emplacement:

文件夹放置:

~/Library/Developer/Xcode/DerivedData/

〜/图书馆/开发人员/Xcode/DerivedData/

enter image description here

在此处输入图片说明

回答by BabyPanda

Set Architecturesto armv7armv7s, Build Active Architecture Onlyto NO, for every target in the project, including every onein Pods

架构ARMv7的armv7s构建有源体系只有NO,在项目的每个目标,包括每一个豆荚

回答by jaytrixz

I fixed mine by checking the selected implementation files in the target membership on the right side. This is useful especially in dealing with extensions i.e. custom keyboards.

我通过检查右侧目标成员资格中的选定实现文件来修复我的问题。这在处理扩展(即自定义键盘)时尤其有用。

Target Membership

目标会员

回答by Moaz Saeed

some explanation why build_active_architecture is set to NO. Xcode now detects which devices you have connected and will set the active architecture accordingly. So if you plug a 2nd generation iPod Touch into your computer Xcode should set the active architecture to armv6. Building your target with the above Debug configuration will now only build the armv6 binary to save time (unless you have a huge project you may not notice the difference but I guess the seconds add up over time).

一些解释为什么 build_active_architecture 设置为 NO。Xcode 现在会检测您连接了哪些设备,并相应地设置活动架构。因此,如果您将第二代 iPod Touch 插入您的计算机,Xcode 应将活动架构设置为 armv6。使用上述 Debug 配置构建目标现在只会构建 armv6 二进制文件以节省时间(除非您有一个庞大的项目,否则您可能不会注意到差异,但我猜秒数会随着时间的推移而增加)。

When you create a Distribution configuration for publishing to the App Store you should make sure this option is not set so that you build the fat universal binary http://useyourloaf.com/blog/2010/04/21/xcode-build-active-architecture-only.html

当您创建用于发布到 App Store 的分发配置时,您应该确保未设置此选项,以便构建胖通用二进制文件 http://useyourloaf.com/blog/2010/04/21/xcode-build-active -architecture-only.html

回答by Tamir Avrahamov

Solved after deleting the content of the DerivedData-->Build-->Products-->Debug-iphoneos

删除DerivedData-->Build-->Products-->Debug-iphoneos的内容后解决

回答by Kalpesh Panchasara

You need to just remove arm64from Valid Architectureand set NOto Active Architecture Only. Now just Clean, Build and Run. You will not see this error again.

您只需从Valid Architecture 中删除arm64并将NO设置为Active Architecture Only。现在只需清理、构建和运行。您不会再看到此错误。

:) KP

:) 知识点