iOS未定义链接器ld错误
问题描述:
我写了一个简单的函数,传入编译器但不传递链接器。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)
答
你要链接到,并#import <SystemConfiguration/SystemConfiguration.h>
,有机会获得圈养网(CN)类和函数。
答
下面是步骤 -
1)点击项目Navigator区域
2)选择 '目标' 选项卡
3)点击 '构建阶段'
4)选择“链接二进制文件库'
5)然后,您可以在区域底部看到'+'按钮。 您现在可以添加所需的SystemConfiguration框架。
#import <SystemConfiguration/SystemConfiguration.h>
听起来像你缺少必需的库或框架,尝试添加SystemConfiguration框架到您的目标。 – danielbeard
新手在这里,我如何用狮子上最新的Xcode做到这一点? – user848106
在侧栏中单击您的项目 - >链接框架和库 - > + - >,然后选择SystemConfiguration框架 – danielbeard