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,059
  • 6
  • 77
  • 111
Suchi
  • 9,889
  • 23
  • 67
  • 111

2 Answers2

77

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

Community
  • 1
  • 1
Joe
  • 56,349
  • 8
  • 124
  • 132
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,155
  • 1
  • 10
  • 19