我寫了一個簡單的函數,傳入編譯器但不傳遞鏈接器。iOS未定義鏈接器ld錯誤
任何想法爲什麼?
- (BOOL) connectedToWifi
{
CFArrayRef myArray = CNCopySupportedInterfaces();
// Get the dictionary containing the captive network infomation
CFDictionaryRef captiveNtwrkDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
NSLog(@"Information of the network we're connected to: %@", captiveNtwrkDict);
NSDictionary *dict = (__bridge NSDictionary*) captiveNtwrkDict;
NSString* ssid = [dict objectForKey:@"SSID"];
if ([ssid rangeOfString:@"WXYZ"].location == NSNotFound || ssid == NULL)
{
return false;
}
else
{
return true;
}
}
這是我的錯誤:
Undefined symbols for architecture i386:
"_CNCopySupportedInterfaces", referenced from:
-[miApp_funcs connectedToWifi] in miApp_funcs.o
"_CNCopyCurrentNetworkInfo", referenced from:
-[miApp_funcs connectedToWifi] in miApp_funcs.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
聽起來像你缺少必需的庫或框架,嘗試添加SystemConfiguration框架到您的目標。 – danielbeard
新手在這裏,我如何用獅子上最新的Xcode做到這一點? – user848106
在側欄中單擊您的項目 - >鏈接框架和庫 - > + - >,然後選擇SystemConfiguration框架 – danielbeard