每次我从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


当前回答

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

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

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

其他回答

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

错误信息是:

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)

解决方案:

进入你的项目 选择目标 然后,转到构建阶段 用库打开二进制链接 最后,只需添加+ AVKit框架/任何其他框架。

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

下面的方法让我在Xcode 5.1上对64位模拟器和retina iPad Mini进行GPUImage编译而没有错误,而不需要从Valid Architectures列表中删除arm64(这违背了拥有一个64位设备来测试64位性能的目的)。

从GitHub页面https://github.com/BradLarson/GPUImage下载。zip文件夹

解压缩,并导航到“框架”文件夹。从这里,添加并复制Source文件夹到你的Xcode项目中。确保勾选了“将项目复制到目标组的文件夹”,并且勾选了“为任何添加的文件夹创建组”。这将复制通用,iOS和Mac头文件/实现文件到你的项目。

如果你不需要Mac文件,因为你正在为iOS编译,你可以在复制文件到你的项目之前删除Mac文件夹,或者简单地从Xcode中删除组。

一旦你将Source文件夹添加到你的项目中,只需使用以下命令开始使用GPUImage的类/方法:

#import "Source/GPUImage.h" 

有几件事需要指出:

If you get an error saying 'Cocoa' not found, you've added the Mac folder/headers into your iOS project - simply delete the Mac group/files from your project and the warning will vanish If you rename the Source folder (not the group in Xcode), use that name instead of "Source/GPUImage.h" in the #import instruction. So if you rename the folder to GPUImageFiles before you add to your project, use: #import "GPUImageFiles/GPUImage.h Obviously ensure arm64 is selected in the Valid Architectures list to take advantage of the A7 64-bit processor! This isn't a GPUImage.framework bundle (such as if you downloaded the framework from http://www.raywenderlich.com/60968/ios-7-blur-effects-gpuimage) so it may not the correct way to use GPUImage that Brad Larson intended, but it works for my current SpriteKit project. There's no need to link to frameworks/libraries etc - just import the header and implementation source folder as described above

希望上面的内容能有所帮助——尽管这个问题被问了很多次,但似乎在任何地方都没有明确的说明,但不要害怕,GPUImage绝对适用于arm64架构!

下面是为什么build_active_architecture设置为NO的一些解释。 Xcode现在会检测你连接了哪些设备,并相应地设置活动架构。所以如果你把第二代iPod Touch插到你的电脑上,Xcode应该把活动架构设置为armv6。用上面的Debug配置构建你的目标现在只构建armv6二进制代码来节省时间(除非你有一个巨大的项目,你可能没有注意到区别,但我猜时间会随着时间的推移而增加)。

当你创建一个发布到App Store的Distribution配置时,你应该确保这个选项没有设置,这样Xcode就会构建一个肥胖的通用二进制文件 http://useyourloaf.com/blog/2010/04/21/xcode-build-active-architecture-only.html

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

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

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