我正在尝试在项目中使用可达性。我添加了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
我该如何解决这个问题?
答案 0 :(得分:42)
您可能忘记将SystemConfiguration.framework添加到项目中。如果您不知道如何添加框架,请查看此SO question。
答案 1 :(得分:3)
添加这些框架.. SystemConfiguration.framework Security.framework CFNetwork.framework
答案 2 :(得分:2)
当我添加Reachability .h和.m文件时,我遇到了同样的错误。
解决方案是确保Reachability .m与其余的.m文件一起编译。你需要这样做。