iOS - _OBJC_CLASS_$_CTTelephonyNetworkInfo 未找到?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8171164/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 15:26:53  来源:igfitidea点击:

iOS - _OBJC_CLASS_$_CTTelephonyNetworkInfo not found?

ioscore-telephony

提问by Suchi

I am using the following code to get network info about my iPhone -

我正在使用以下代码获取有关我的 iPhone 的网络信息 -

#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>


CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netInfo subscriberCellularProvider];
NSString *osVersion = [[UIDevice currentDevice] systemVersion];

But I get the error -

但我得到了错误 -

Undefined symbols for architecture armv7:
 "_OBJC_CLASS_$_CTTelephonyNetworkInfo", referenced from:
  objc-class-ref in MyClass.o
ld: symbol(s) not found for architecture armv7

Isn't the class a part of the iOS SDK? What am I doing wrong?

该类不是 iOS SDK 的一部分吗?我究竟做错了什么?

回答by Joe

It is part of the CoreTelephony.framework. You need to add that frameworkfor your code to work.

它是CoreTelephony.framework 的一部分。您需要为您的代码添加该框架才能工作。

回答by Lasse

I had a similar issue. Mine was related to having multiple targets, where it would fail on only 1 target.

我有一个类似的问题。我的与有多个目标有关,它只会在 1 个目标上失败。

To resolve it I had to ctrl-click the CoreTelephone.framework and select to add it to all my schemes.

要解决它,我必须按住 ctrl 单击 CoreTelephone.framework 并选择将其添加到我的所有方案中。

The exact error I was getting was "Undefined symbols for architecture i386: "_OBJC_CLASS_$_CTTelephonyNetworkInfo","

我得到的确切错误是“架构 i386 的未定义符号:”_OBJC_CLASS_$_CTTelephonyNetworkInfo”,”