Apple Mach-O Linker Errors (20) - 架构 armv7 的未定义符号

Posted

技术标签:

【中文标题】Apple Mach-O Linker Errors (20) - 架构 armv7 的未定义符号【英文标题】:Apple Mach-O Linker Errors (20) - Undefined symbols for architecture armv7 【发布时间】:2012-04-13 11:05:09 【问题描述】:

在添加“libPusher-combined.a”及其头文件后,在“其他链接器标志”构建设置中添加“-all_load”后,我收到了这些错误。我完全按照instructions 输入“-all_load”的部分(在“添加到您的 ios 项目”中的“使用预编译的静态库”下,但我最终得到了 20 个 Mach-O 链接器错误. :/ 谁能帮我解决这个问题?

以下是错误:

Undefined symbols for architecture armv7:
 "_utf8_nextCharSafeBody", referenced from:
  -[SRWebSocket _pumpScanner] in libPusher-combined.a(SRWebSocket.o)
 "_SCError", referenced from:
  -[Reachability startNotifier] in libPusher-combined.a(Reachability.o)
 "_utf8_countTrailBytes", referenced from:
  -[SRWebSocket _pumpScanner] in libPusher-combined.a(SRWebSocket.o)
 "_SCNetworkReachabilitySetDispatchQueue", referenced from:
  -[Reachability startNotifier] in libPusher-combined.a(Reachability.o)
  -[Reachability stopNotifier] in libPusher-combined.a(Reachability.o)
 "_kCFHTTPVersion1_1", referenced from:
  -[SRWebSocket didConnect] in libPusher-combined.a(SRWebSocket.o)
"_CFHTTPMessageIsHeaderComplete", referenced from:
  ___30-[SRWebSocket _readHTTPHeader]_block_invoke_0 in libPusher-combined.a(SRWebSocket.o)
 "_CFHTTPMessageCreateRequest", referenced from:
  -[SRWebSocket didConnect] in libPusher-combined.a(SRWebSocket.o)
 "_SCNetworkReachabilityCreateWithAddress", referenced from:
  +[Reachability reachabilityWithAddress:] in libPusher-combined.a(Reachability.o)
 "_SCErrorString", referenced from:
  -[Reachability startNotifier] in libPusher-combined.a(Reachability.o)
 "_SCNetworkReachabilityCreateWithName", referenced from:
  +[Reachability reachabilityWithHostname:] in libPusher-combined.a(Reachability.o)
 "_CFHTTPMessageCopyAllHeaderFields", referenced from:
  ___30-[SRWebSocket _readHTTPHeader]_block_invoke_0 in libPusher-combined.a(SRWebSocket.o)
 "_CFHTTPMessageGetResponseStatusCode", referenced from:
  -[SRWebSocket _HTTPHeadersDidFinish] in libPusher-combined.a(SRWebSocket.o)
 "_CFHTTPMessageSetHeaderFieldValue", referenced from:
  -[SRWebSocket didConnect] in libPusher-combined.a(SRWebSocket.o)
  ___25-[SRWebSocket didConnect]_block_invoke_0 in libPusher-combined.a(SRWebSocket.o)
 "_CFHTTPMessageCreateEmpty", referenced from:
  -[SRWebSocket _readHTTPHeader] in libPusher-combined.a(SRWebSocket.o)
 "_CFHTTPMessageCopySerializedMessage", referenced from:
  -[SRWebSocket didConnect] in libPusher-combined.a(SRWebSocket.o)
 "_SCNetworkReachabilitySetCallback", referenced from:
  -[Reachability startNotifier] in libPusher-combined.a(Reachability.o)
  -[Reachability stopNotifier] in libPusher-combined.a(Reachability.o)
 "_SCNetworkReachabilityGetFlags", referenced from:
  -[Reachability isReachable] in libPusher-combined.a(Reachability.o)
  -[Reachability isReachableViaWWAN] in libPusher-combined.a(Reachability.o)
  -[Reachability isReachableViaWiFi] in libPusher-combined.a(Reachability.o)
  -[Reachability connectionRequired] in libPusher-combined.a(Reachability.o)
  -[Reachability isConnectionOnDemand] in libPusher-combined.a(Reachability.o)
  -[Reachability isInterventionRequired] in libPusher-combined.a(Reachability.o)
  -[Reachability reachabilityFlags] in libPusher-combined.a(Reachability.o)
  ...
 "_CFHTTPMessageCopyHeaderFieldValue", referenced from:
  -[SRWebSocket _checkHandshake:] in libPusher-combined.a(SRWebSocket.o)
 "_CFHTTPMessageAppendBytes", referenced from:
  ___30-[SRWebSocket _readHTTPHeader]_block_invoke_0 in libPusher-combined.a(SRWebSocket.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

如果您需要更多信息,请尽管询问。我希望我没有给太多麻烦。提前致谢。

【问题讨论】:

【参考方案1】:

检查以确保您包含以下框架(通过https://github.com/square/SocketRocket):

框架依赖

您的 .app 必须与以下框架/dylib 链接

libicucore.dylib CFNetwork.framework 安全框架 Foundation.framework

【讨论】:

为 PonyDebugger 添加了一个 cocoapod。解决方案奏效。谢谢! 我刚刚添加了第一个 libicucore.dylib 并修复了问题(Foundation.framework 已经存在)。【参考方案2】:

确保在构建设置选项卡的“其他链接器标志”中也有 -licucore,如随附的屏幕截图所示:

【讨论】:

谢谢。那是我的解决方案 也帮帮我。更新到 Xcode 7 后,由于某种原因已将其删除。【参考方案3】:

我将完整的 SocketRocket 文件夹复制到我的应用程序中,以便在我的应用程序中使用 Web 套接字,并将 libicucore.dylib、CFNetwork.framework、Security.framework、Foundation.framework 二进制文件与我的项目相关联。这消除了我所有的错误和警告。

【讨论】:

【参考方案4】:

对于最新的sdk,你应该添加:

libicucore.tbd 

因为 libicucore.dylib 不再存在。

希望 .tbd 扩展名不是为了“被删除”?

【讨论】:

【参考方案5】:

你能在你的目标->构建阶段签出吗?这些文件是否存在?如果你正在为模拟器运行,那么首先你需要为该库的模拟器构建一个我猜你正在使用 SRWebSocket 库的库。只需打开该项目并为模拟器进行构建并从构建文件夹复制文件,然后添加到您的项目中,如果您在设备上运行应用程序,则对设备执行相同操作。

【讨论】:

如果您仍然遇到任何问题,请告诉我。 :) 嗯,它成功了,错误消失了,但它们被 13 个警告所取代。 嗯,那些警告我猜你可以解决。或者只是告诉我们这些警告,让我们看看我能不能帮你。 哎呀。虚惊;除了 13 个警告之外,还有 20 个错误。 我一开始试图消除的相同错误仍然存​​在。但现在,我还有 14 条新警告。【参考方案6】:

就我而言,当我将 SystemConfiguration.framework 添加到项目中时,问题出现了...... :-)

【讨论】:

以上是关于Apple Mach-O Linker Errors (20) - 架构 armv7 的未定义符号的主要内容,如果未能解决你的问题,请参考以下文章

更新到 XCode 8.3.1:Apple Mach-O Linker Error Group with Snapkit error

在 iOS5 中实现库时获取“apple mach-o linker id error undefined symbols for architecture i386”

如何删除 Xcode 警告 Apple Mach-O Linker Warning 'Pointer notalign at address

Apple Mach-O Linker Errors (20) - 架构 armv7 的未定义符号

CocoaAsyncSocket Apple Mach-O 链接器错误

Apple Mach-O 链接器 (ld) 错误 swift 3.0 和 Xcode 8.3.3