gpt4 book ai didi

iOS 未定义链接器 ld 错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:09:38 25 4
gpt4 key购买 nike

我写了一个简单的函数,通过了编译器但没有通过链接器。

知道为什么吗?

- (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)

最佳答案

以下是步骤-

1) 在Navigator区域点击project

2) 选择“目标”标签

3) 点击“构建阶段”

4) 选择“将二进制文件与库链接”

5) 然后您可以在该区域的底部看到“+”按钮。 您现在可以添加所需的 SystemConfiguration 框架。

#import <SystemConfiguration/SystemConfiguration.h>

关于iOS 未定义链接器 ld 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10809143/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com