user1051935
user1051935

Reputation: 589

unable to use the reachability functionality of objective C

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?

Upvotes: 1

Views: 980

Answers (1)

Tommy
Tommy

Reputation: 100652

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.

Upvotes: 3

Related Questions