LuckyLuke
LuckyLuke

Reputation: 49087

Adding Reachability class fails when I am trying to build

I have added the SystemConfiguration framework. I am deploying against targets from 3.2 and higher. Have I forgotten to add something?

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_Reachability", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Upvotes: 12

Views: 12619

Answers (3)

avyk37
avyk37

Reputation: 326

I had a similar problem when I upgraded to the newest version of Mixpanel. The error read:

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_CTTelephonyNetworkInfo", referenced from:
      objc-class-ref in Mixpanel.o

You can follow Damo's solution until the last step, and then instead of expanding the Compile Sources section, you have to expand the Link Binary With Libraries section instead, and add the CoreTelephony.framework source which contains CTTelephonyNetworkInfo.

You can read more about the CTTelephonyNetworkInfo class reference on Apple's official website here: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Reference/CTTelephonyNetworkInfo/Reference/Reference.html

Upvotes: 0

Developer
Developer

Reputation: 6465

You might have forgotten to include the Reachability classes in your project!

Upvotes: 1

Damo
Damo

Reputation: 12900

Okay, the clues are all in the error report you have posted.

While linking (the message is from the linker ld) which occurs after compilation of all the symbols across your project, the message is saying

"In AppDelegate, you have referenced a class object called Reachability"

"_OBJC_CLASS_$_Reachability"

and as far as the linker is concerned Reachability is undefined.

So, check that Reachability is being compiled in your project. The are a couple of ways to do this. Perhaps the most clear way is to enter image description here

1 select the project file in the navigation pane

2 select the target

3 select Build Phases

4 Expand the Compile Sources section

*Now check the list of sources that will be compiled for your missing class, in your case Reachability.m

If it is missing, use the + button to add the file to the target.

Another way is to

enter image description here

1 select the file you think is not being compiled

2 open the utilities panel

3 select the file inspector tab

There will be a checkbox for each target in your project and you can easily see if your .m file is being compiled for each/all targets or not.

Upvotes: 41

Related Questions