Apple的Reachability文件中存在奇怪的错误

时间:2012-06-13 11:33:41

标签: objective-c ios

我正在尝试在项目中使用可达性。我添加了Reachability.h和Reachability.m文件。但是在构建项目之后,xCode显示了奇怪的错误:

Undefined symbols for architecture i386:
"_SCNetworkReachabilityCreateWithName", referenced from:
  +[Reachability reachabilityWithHostname:] in Reachability.o
"_SCNetworkReachabilityCreateWithAddress", referenced from:
  +[Reachability reachabilityWithAddress:] in Reachability.o
"_SCNetworkReachabilitySetCallback", referenced from:
  -[Reachability startNotifier] in Reachability.o
  -[Reachability stopNotifier] in Reachability.o
"_SCError", referenced from:
  -[Reachability startNotifier] in Reachability.o
"_SCErrorString", referenced from:
  -[Reachability startNotifier] in Reachability.o
"_SCNetworkReachabilitySetDispatchQueue", referenced from:
  -[Reachability startNotifier] in Reachability.o
  -[Reachability stopNotifier] in Reachability.o
"_SCNetworkReachabilityGetFlags", referenced from:
  -[Reachability isReachable] in Reachability.o
  -[Reachability isReachableViaWWAN] in Reachability.o
  -[Reachability isReachableViaWiFi] in Reachability.o
  -[Reachability connectionRequired] in Reachability.o
  -[Reachability isConnectionOnDemand] in Reachability.o
  -[Reachability isInterventionRequired] in Reachability.o
  -[Reachability reachabilityFlags] in Reachability.o

我该如何解决这个问题?

3 个答案:

答案 0 :(得分:42)

您可能忘记将SystemConfiguration.framework添加到项目中。如果您不知道如何添加框架,请查看此SO question

答案 1 :(得分:3)

添加这些框架..     SystemConfiguration.framework     Security.framework     CFNetwork.framework

答案 2 :(得分:2)

当我添加Reachability .h和.m文件时,我遇到了同样的错误。

解决方案是确保Reachability .m与其余的.m文件一起编译。你需要这样做。

  1. 点击项目导航器 - 播放/停止按钮下方左上角的文件夹图标。
  2. 选择目标
  3. 点击“Build Phases”。
  4. 点击“+”图标。并将Reachability.m文件添加到编译源。