架构 i386 的未定义符号:“_SCNetworkReachabilitySetCallback”

Posted

技术标签:

【中文标题】架构 i386 的未定义符号:“_SCNetworkReachabilitySetCallback”【英文标题】:Undefined symbols for architecture i386: "_SCNetworkReachabilitySetCallback" 【发布时间】:2011-10-30 01:35:30 【问题描述】:

我在 openglES 项目中使用 xcode4 我从教程中添加了应用内购买代码: http://www.raywenderlich.com/2797/introduction-to-in-app-purchases

我添加了 SystemConfiguration.framework 但出现此错误:

Ld /Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Products/Debug-iphonesimulator/blatest.app/blatest normal i386
    cd /Users/Eros/Desktop/blatestDB
    setenv MACOSX_DEPLOYMENT_TARGET 10.6
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Products/Debug-iphonesimulator -F/Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Products/Debug-iphonesimulator -F/Users/Eros/Desktop/blatestDB -filelist /Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Intermediates/blatest.build/Debug-iphonesimulator/SLQTSOR.build/Objects-normal/i386/blatest.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore -framework AVFoundation -framework AudioToolbox -framework CoreAudio -framework CoreGraphics -framework OpenAL -lz -framework MediaPlayer -framework AVFoundation -framework GameKit -framework StoreKit -o /Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Products/Debug-iphonesimulator/blatest.app/blatest

Undefined symbols for architecture i386:
  "_SCNetworkReachabilitySetCallback", referenced from:
      -[Reachability startNotifier] in Reachability.o
  "_SCNetworkReachabilityScheduleWithRunLoop", referenced from:
      -[Reachability startNotifier] in Reachability.o
  "_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:
      -[Reachability stopNotifier] in Reachability.o
  "_SCNetworkReachabilityGetFlags", referenced from:
      -[Reachability currentReachabilityStatus] in Reachability.o
      -[Reachability connectionRequired] in Reachability.o
  "_SCNetworkReachabilityCreateWithName", referenced from:
      +[Reachability reachabilityWithHostName:] in Reachability.o
  "_SCNetworkReachabilityCreateWithAddress", referenced from:
      +[Reachability reachabilityWithAddress:] in Reachability.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

如果我删除框架引用,错误是一样的。 再次添加没有任何反应... 在 -Xlinker 2 -framework Foundation -framework UIKit [...] 我应该看到“-framework SystemConfiguration”吗? 为什么不存在? 有人有想法吗?

从项目中提取框架->构建阶段->将二进制文件与库链接,使其成为我遇到此错误的第一个框架:

Ld /Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Products/Debug-iphonesimulator/blatest.app/blatest normal i386
    cd /Users/Eros/Desktop/blatestDB
    setenv MACOSX_DEPLOYMENT_TARGET 10.6
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Products/Debug-iphonesimulator -F/Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Products/Debug-iphonesimulator -F/Users/Eros/Desktop/blatestDB -filelist /Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Intermediates/blatest.build/Debug-iphonesimulator/SLQTSOR.build/Objects-normal/i386/blatest.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework SystemConfiguration -framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore -framework AVFoundation -framework AudioToolbox -framework CoreAudio -framework CoreGraphics -framework OpenAL -lz -framework MediaPlayer -framework AVFoundation -framework GameKit -framework StoreKit -o /Users/Eros/Library/Developer/Xcode/DerivedData/blatest-acmdklrqungznggpjewgxuxqsvwo/Build/Products/Debug-iphonesimulator/blatest.app/blatest

ld: warning: ignoring file /Users/Eros/Desktop/blatestDB/SystemConfiguration.framework/SystemConfiguration, missing required architecture i386 in file
Undefined symbols for architecture i386:
  "_SCNetworkReachabilitySetCallback", referenced from:
      -[Reachability startNotifier] in Reachability.o
  "_SCNetworkReachabilityScheduleWithRunLoop", referenced from:
      -[Reachability startNotifier] in Reachability.o
  "_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:
      -[Reachability stopNotifier] in Reachability.o
  "_SCNetworkReachabilityGetFlags", referenced from:
      -[Reachability currentReachabilityStatus] in Reachability.o
      -[Reachability connectionRequired] in Reachability.o
  "_SCNetworkReachabilityCreateWithName", referenced from:
      +[Reachability reachabilityWithHostName:] in Reachability.o
  "_SCNetworkReachabilityCreateWithAddress", referenced from:
      +[Reachability reachabilityWithAddress:] in Reachability.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

SystemConfiguration 在那里,错误仍然在那里...... 会是什么? 谢谢

【问题讨论】:

【参考方案1】:

找到了! 我已将 SystemConfiguration.framework 复制到我的项目文件夹中(当我从 xcode 添加时选中该框)。 在我的项目中删除该文件夹现在编译良好​​p>

【讨论】:

【参考方案2】:

在构建阶段添加SystemConfiguration.framework 后,我的项目编译良好...

玩得开心...!

【讨论】:

【参考方案3】:

我也有同样的问题。我直接通过拖放添加了一些框架。

为了解决这个问题,我删除了所有这些并通过菜单 Target>Build Phases 添加它们,然后再次通过 Link Binary With Libraries 添加所有需要的框架。

在此之后,您的代码应该可以再次正常工作了。

【讨论】:

【参考方案4】:

很简单。

scnetworkreachability 回调被标记为未定义符号,这意味着缺少某些库或框架文件

前缀sc表示系统配置

点击项目名称选择右侧的Summary

点击链接二进制文件和框架

点击加号然后你可以看到一个包含框架和库集合的向下钻取看看是否有任何调用 系统配置框架

选择它并按确定

现在buildrun问题解决了

【讨论】:

【参考方案5】:

当我使用 AFNetworking 时,在收到这些错误后导入了 3 个框架

CFNetwork.framework
Security.framework
SystemConfiguration.framework

所有错误都会消失.. 享受吧!!!

【讨论】:

【参考方案6】:

如上所述,导入以下3个框架后,就可以了!

    CFNetwork.framework
    Security.framework
    SystemConfiguration.framework

非常感谢!

【讨论】:

【参考方案7】:

我想指出我也遇到了与此类似的问题。

我将一些文件复制到 xcode 并意外选择了“ProjectTests”而不是项目。只需删除文件并将它们重新添加到您的项目中,确保选择主项目(而不是单元测试)

【讨论】:

【参考方案8】:

从 repo 更新后我遇到了同样的问题。

对我有用的解决方案是从项目中删除所有类的引用并再次添加它们。问题是很可能会搞乱 repo 同步。

【讨论】:

以上是关于架构 i386 的未定义符号:“_SCNetworkReachabilitySetCallback”的主要内容,如果未能解决你的问题,请参考以下文章

架构 i386 的未定义符号:“_SCNetworkReachabilitySetCallback”

架构 i386 的未定义符号 - Lipo 错误?

“架构 i386 的未定义符号”问题

架构 i386 的未定义符号:_FlutterMethodNotImplemented

架构 i386 的未定义符号:用于 OpenCV 项目

架构 i386 的未定义符号:“_OBJC_CLASS_$_RCTBundleURLProvider”