I was recently adding some code to check for the availability of the network, so I can display an error to the user if unavailable.
I looked at the SeismicXML application and borrowed the following code:
// Use the SystemConfiguration framework to determine if the host that provides
// the RSS feed is available.
- (BOOL)isDataSourceAvailable
{
static BOOL checkNetwork = YES;
if (checkNetwork) {
// Since checking the reachability of a host can be expensive,
// cache the result and perform the reachability check once.
checkNetwork = NO;
Boolean success;
const char *host_name = "earthquake.usgs.gov";
//const char *host_name = "localhost";
SCNetworkReachabilityRef reachability =
SCNetworkReachabilityCreateWithName(NULL, host_name);
SCNetworkReachabilityFlags flags;
success = SCNetworkReachabilityGetFlags(reachability, &flags);
_isDataSourceAvailable = success &&
(flags & kSCNetworkFlagsReachable) &&
!(flags & kSCNetworkFlagsConnectionRequired);
CFRelease(reachability);
}
return _isDataSourceAvailable;
}
I wouldn’t compile unless I added the following import:
#import <SystemConfiguration/SystemConfiguration.h>
After adding this I still go 2 more errors, but these were a bit more cryptic.
Undefined symbols:
"_SCNetworkReachabilityCreateWithName", referenced from:
-[TheElementsAppDelegate isDataSourceAvailable] in TheElementsAppDelegate.o
"_SCNetworkReachabilityGetFlags", referenced from:
-[TheElementsAppDelegate isDataSourceAvailable] in TheElementsAppDelegate.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
After some digging around I realized that I was missing the SystemConfiguration.framework framework.
So here is what I did to add it.
1. I right click on “Frameworks” and choose: Add < Existing Framework

2. Browsed to the file: /System/Library/Frameworks/SystemConfiguration.framework
3. Rebuilt the project and my error was gone.
If you like this post and would like to receive updates from this blog, please subscribe our feed.
February 24th, 2009 at 2:07 am
Thanks for this. This was a huge help! Between the Reachability app examples and the Seismic XML examples, this was by far the best tutorial I could find on the topic. Thank you! Thank you! Thank you! You saved me hours of head scratching.
May 2nd, 2009 at 5:52 am
Thanks for posting this. It’s been a big help! Thanks, Jason.
July 29th, 2009 at 8:11 pm
Thanks a ton. This filled in the gaps that I needed!
September 2nd, 2009 at 1:13 pm
Great Post. I am still getting those two exact errors, even after I added the framework.
any ideas?
Thanks!
April 27th, 2010 at 2:54 pm
Quite awhile since you posted this, but wanted to say it saved me. Thanks for the post.
October 16th, 2011 at 8:35 am
I had the System.configuration.framework, but I was still getting the error.
SO I had to readd it ( dont ask me why ) and restart my xcode.
And thats how i got it working.