19

I am using the following code to get network info about my 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?

JOM
  • 8,139
  • 6
  • 78
  • 111
Suchi
  • 9,989
  • 23
  • 68
  • 112

2 Answers2

78

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

Community
  • 1
  • 1
Joe
  • 56,979
  • 9
  • 128
  • 135
4

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

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

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

Lasse
  • 1,153
  • 1
  • 10
  • 21