How to check server availability

Possible duplicate:
Undefined symbols for armv7 architecture: "_SCNetworkReachabilityCreateWithAddress"

I tried a couple of things that I found here and no one worked. I have added Apple .h and .m reachability files to my project. I am trying to check the availability of the mogul server, and the following code that I used in my real program:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNetworkChange:) name:kReachabilityChangedNotification object:nil]; reach = [Reachability reachabilityForInternetConnection]; [reach startNotifier]; NetworkStatus remoteHostStatus = [reach currentReachabilityStatus]; if (remoteHostStatus == NotReachable) { NSLog(@"no"); textTest.text = @"Can't reach it"; } else if(remoteHostStatus == ReachableViaWiFi || remoteHostStatus == ReachableViaWWAN){ NSLog(@"Yes"); textTest.text = @"Got it"; } testServer.hidden = YES; .... -(void)handleNetworkChange:(NSNotification *)notice{ NetworkStatus remoteHostStatus = [reach currentReachabilityStatus]; if (remoteHostStatus == NotReachable) { NSLog(@"no"); textTest.text = @"Can't get it"; } else if(remoteHostStatus == ReachableViaWiFi || remoteHostStatus == ReachableViaWWAN){ NSLog(@"Got it"); textTest.text = @"Got it"; } } 

and in the .h file:

 @property (retain, nonatomic) Reachability *reach; .... -(void)handleNetworkChange:(NSNotification *)notice; 

Every time I try to compile and run, this is what I get:

 Ld /Users/ConorMccallion/Library/Developer/Xcode/DerivedData/newClient-aunayptutxnlhjeoflldefcmybpk/Build/Products/Debug-iphonesimulator/newClient.app/newClient normal i386 cd /Volumes/TRAVELDRIVE/Reseaech/ClientSide/newClient setenv IPHONEOS_DEPLOYMENT_TARGET 6.0 setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk -L/Users/ConorMccallion/Library/Developer/Xcode/DerivedData/newClient-aunayptutxnlhjeoflldefcmybpk/Build/Products/Debug-iphonesimulator -F/Users/ConorMccallion/Library/Developer/Xcode/DerivedData/newClient-aunayptutxnlhjeoflldefcmybpk/Build/Products/Debug-iphonesimulator -filelist /Users/ConorMccallion/Library/Developer/Xcode/DerivedData/newClient-aunayptutxnlhjeoflldefcmybpk/Build/Intermediates/newClient.build/Debug-iphonesimulator/newClient.build/Objects-normal/i386/newClient.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=6.0 -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/ConorMccallion/Library/Developer/Xcode/DerivedData/newClient-aunayptutxnlhjeoflldefcmybpk/Build/Products/Debug-iphonesimulator/newClient.app/newClient Undefined symbols for architecture i386: "_SCNetworkReachabilityCreateWithAddress", referenced from: +[Reachability reachabilityWithAddress:] in ViewController.o +[Reachability reachabilityWithAddress:] in Reachability.o "_SCNetworkReachabilityCreateWithName", referenced from: +[Reachability reachabilityWithHostName:] in ViewController.o +[Reachability reachabilityWithHostName:] in Reachability.o "_SCNetworkReachabilityGetFlags", referenced from: -[Reachability connectionRequired] in ViewController.o -[Reachability currentReachabilityStatus] in ViewController.o -[Reachability connectionRequired] in Reachability.o -[Reachability currentReachabilityStatus] in Reachability.o "_SCNetworkReachabilityScheduleWithRunLoop", referenced from: -[Reachability startNotifier] in ViewController.o -[Reachability startNotifier] in Reachability.o "_SCNetworkReachabilitySetCallback", referenced from: -[Reachability startNotifier] in ViewController.o -[Reachability startNotifier] in Reachability.o "_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from: -[Reachability stopNotifier] in ViewController.o -[Reachability stopNotifier] in Reachability.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) 

This is probably something obvious, so the answer would be greatly appreciated. thank you

+4
source share
2 answers

If you want to check the availability of a specific host, you can use the following code,

 Reachability *reach = [Reachability reachabilityWithHostName:@"www.apple.com"]; 

Here you can pass the name of your server as the host name to check availability. It should work. See the apple documentation for more details.

For the error message you are getting, try adding SystemConfiguration.framework to the project. If this does not help, check this Undefined symbol for armv7 architecture: "_SCNetworkReachabilityCreateWithAddress" .

+3
source

on did the FinishLaunchingWithOptions method put:

self.internetReach= [Reachability reachabilityWithHostName:@"your host name egwww.apple.com"];

 [internetReach startNotifier]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil]; [self performSelector:@selector(reachabilityChanged:) withObject:[NSNotification notificationWithName:kReachabilityChangedNotification object:internetReach]]; 

this will call the method below

 - (void)reachabilityChanged:(NSNotification*)note 

{

 Reachability* curReach = [note object]; NSParameterAssert([curReach isKindOfClass: [Reachability class]]); if(curReach == self.internetReach) { NetworkStatus netStatus = [curReach currentReachabilityStatus]; switch (netStatus) { case ReachableViaWiFi: { isInternetConnectionAvilable=YES; if(isNetworkNotifierCalledOnce) { UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Message!" message:@"Internet Available Now" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; } break; } case NotReachable: { isInternetConnectionAvilable=NO; UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Message!" message:@"No Internet Connectivity" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; break; } } } isNetworkNotifierCalledOnce=YES; 

}

0
source

All Articles