Wifi

Undefined symbols for architecture i386 – Reachability

Today I add the Reachability classes to an app I am working on, added my #import Reachability.h to the correct files and then implemented a method to check if the device was using wifi.

When I hit build, I got the following error.

Undefined symbols for architecture i386:
"_SCNetworkReachabilityCreateWithAddress", referenced from:
+[Reachability reachabilityWithAddress:] in Reachability.o
"_SCNetworkReachabilityCreateWithName", referenced from:
+[Reachability reachabilityWithHostName:] in Reachability.o
"_SCNetworkReachabilityGetFlags", referenced from:
-[Reachability connectionRequired] in Reachability.o
-[Reachability currentReachabilityStatus] in Reachability.o
"_SCNetworkReachabilityScheduleWithRunLoop", referenced from:
-[Reachability startNotifier] in Reachability.o
"_SCNetworkReachabilitySetCallback", referenced from:
-[Reachability startNotifier] in Reachability.o
"_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:
-[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)

 

I figured it was a framework that I had forgotten to add to I added the CFNetwork.framework and hit build again, same error again. I then added SystemConfiguration.framework into the project and hit build, and success!!

It was such a simple fix but the errors that were displayed weren’t really helpful with explaining what framework needed to be added.

iOS – Check if wifi is being used

In an app I was making recently I wanted to check if the user was using a wifi connection. I used the method below to check and just checked whether it returned true or false.

- (BOOL)networkCheck{
 Reachability *currentReachability = [[Reachability reachabilityForInternetConnection] retain];
 NetworkStatus networkStatus = [currentReachability currentReachabilityStatus];
 [currentReachability release];
switch (networkStatus)
 {
 case NotReachable: {
 NSLog(@"Not connected");
 return false;
 break;
 }
 
case ReachableViaWWAN:{
 NSLog(@"Cellular Network");
 return false;
 break;
 }
 
case ReachableViaWiFi:{
 NSLog(@"Wifi");
 return true;
 break;
 }
 }
 
return false;
}
 Scroll to top