2012-06-13 34 views
16

我正在嘗試在我的項目中使用可達性。我添加了Reachability.h和Reachability.m文件。但建設項目xCode後顯示我奇怪的錯誤:Apple的可訪問性文件中的奇怪錯誤

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

是否添加了所需的框架? – doNotCheckMyBlog

回答

41

您可能忘了將SystemConfiguration.framework添加到您的項目中。如果您不知道如何添加框架,請查看SO question

3

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

2

當我加入了可達性h和.m文件我有同樣的錯誤。

解決方案是確保Reachability .m與您的.m文件的其餘部分一起編譯。你需要這樣做。

  1. 點擊項目導航器 - 播放/停止按鈕下左上角的文件夾圖標。
  2. 選擇目標
  3. 點擊「構建階段」。
  4. 點擊「+」圖標。並將Reachability.m文件添加到您的編譯源中。