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

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

我有大约12个这样的耳机,用于我使用的各种pod。

我试图使用XCode 5为iPhone 5S构建。

我一直在尝试各种解决方案这里所以,但还没有得到任何工作。

我如何解决这个苹果Mach-O链接错误?


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

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

~/Library/Developer/Xcode/DerivedData/someApp/Build/Products/Debug-iphoneos/libPods.a


当前回答

我也遇到过同样的问题。 我在这里找到的解决方案:为什么链接器链接带有错误的静态库?iOS

添加$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)到库搜索路径解决了这个问题。

其他回答

这个错误花费了我一整天的时间,所以我想写一些真正对我有用的东西

删除.xworkspace 删除podfile.lock 删除Pods文件夹/目录

“不删除podfile”

在这之后,CLEAN(OPTION + SHIFT + CMD + K)——> BUILD(CMD + B)——> RUN(CMD + R)

我希望这真的对你有用:)

如果你正在使用m1 (arm64),你有问题,你可以在x86模式下运行:

右键点击xcode,点击获取信息按钮 勾选“使用罗塞塔”选项打开

这将是一个缓慢但有效的过程。

问题是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.

编辑:有些人还报告说,将为活动架构构建设置为YES也是解决这个问题的必要条件。

截至2014-04-28,设置应该是这样的:

希望能帮到你。我添加了框架,问题已经解决了

如果架构和链接器设置看起来不错,请检查h文件。我的问题是同样的错误,但我已经重新构造了h文件,我删除了一个extern语句。其他m文件正在使用该变量,导致链接器错误。