1

I am using XCode 4.3 and trying to check if the user has internet connection

I am using the reachability functions that are provided by apple but when I create an instance using this line

 Reachability *curReach= [Reachability reachabilityWithHostName:@"http://www.google.com"];

I get the following errors :

"_OBJC_CLASS_$_Reachability", referenced from:
      objc-class-ref in classfile.m

and

ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have included reachability.h and .m and I included the following in my .h and my .m file :

#import <SystemConfiguration/SystemConfiguration.h>
#import <Foundation/Foundation.h>
#import <CoreFoundation/CoreFoundation.h>

#include <netinet/in.h>
#import "Reachability.h"

#import <sys/socket.h>
#import <netinet/in.h>
#import <netinet6/in6.h>
#import <arpa/inet.h>
#import <ifaddrs.h>
#import <netdb.h>

any reason why I am getting this error?

user1051935
  • 579
  • 1
  • 10
  • 29

1 Answers1

3

You've possibly chopped the error message a little too tightly, but it looks like a link-time error warning you that the Reachability class isn't part of your final binary, despite the interface having been visible while building.

So either you're using a static library for the reachability code and have built it for ARM (ie, actual device deployment), or you've neglected to include Apple's Reachability.m in your target. Possibly the easiest way to check the latter is to enable the right panel, select Reachability.m and look for a suitable tick under the 'Target Membership' heading.

Tommy
  • 99,986
  • 12
  • 185
  • 204
  • I checked the targets and when I added reachability.m in my target , the number of errors increased to 10 errors , all in the reachability.m fileand all related to ARC and (I assume) things related to previous XCode Versions ( I am not sure since I am new to iOS development) . is it safe to play in the reachability.m file ? – user1051935 Apr 02 '12 at 19:11
  • 1
    It should be, and reachability.m definitely isn't set up for ARC as written, though it might be easier to follow the advice in http://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-in-a-project and disable ARC for that one source file only. – Tommy Apr 02 '12 at 19:20