Possible Duplicate:
Undefined symbols for architecture armv7: “_SCNetworkReachabilityCreateWithAddress”
I tried a couple of things I found on here, and none have worked. I added the reachability.h and .m files from Apple to my project. I'm trying to test the reachability of a mogul server, and the following is the code I used within my actual 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)
It's probably something obvious, so an answer would be greatly appreciated. Thank you
If you want to check the reachability of a particular host, you can use the following code,
Reachability *reach = [Reachability reachabilityWithHostName:@"www.apple.com"];
Here you can pass your server name as the host name to check the reachability. It should work. Check the apple documentation for more details.
For the error message you are getting, try adding SystemConfiguration.framework
to the project. If that doesn't help, check this Undefined symbols for architecture armv7: "_SCNetworkReachabilityCreateWithAddress".