|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Error With my Implementation of Reachability to Check if Connected to Internet
Hi
I'm trying to implement reachability into my iPhone app to allow me to determine if the user has an internet connection. Unfortunately, I am getting two errors whilst trying to build the app. These are the steps I took to implement it: I added the SystemConfiguration framework and added Reachability.h/.m to my classes folder. I then added this to my viewcontroller.h file for the viewcontroller in which I am detecting an internet connection: Code:
//Class.h #import "Reachability.h" #import <SystemConfiguration/SystemConfiguration.h> - (BOOL)connected ; Code:
In my .m file, I use this code as a boolean method, which when run will return if the user has an internet connection:
- (BOOL)connected
{
Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [reachability currentReachabilityStatus];
return !(networkStatus == NotReachable);
}
Code:
if(![self connected])
{
// not connected
} else
{
// connected, do some internet stuff
}
Code:
Ld /Users/Samuel/Library/Developer/Xcode/DerivedData/Funny_Maths-ctillajbcxujxhdywykbwodfufrw/Build/Products/Debug-iphonesimulator/reactionfree.app/reactionfree normal i386
cd "/Users/Samuel/Documents/Projects/Apps/Funny Math Reachability"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
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/iPhoneSimulator5.1.sdk -L/Users/Samuel/Library/Developer/Xcode/DerivedData/Funny_Maths-ctillajbcxujxhdywykbwodfufrw/Build/Products/Debug-iphonesimulator "-L/Users/Samuel/Documents/Projects/Apps/Funny Math Reachability/GoogleAdMobAdsSDKiOS-5.0.5" -F/Users/Samuel/Library/Developer/Xcode/DerivedData/Funny_Maths-ctillajbcxujxhdywykbwodfufrw/Build/Products/Debug-iphonesimulator -filelist "/Users/Samuel/Library/Developer/Xcode/DerivedData/Funny_Maths-ctillajbcxujxhdywykbwodfufrw/Build/Intermediates/Funny Maths.build/Debug-iphonesimulator/Funny Maths.build/Objects-normal/i386/reactionfree.LinkFileList" -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50100 -framework SystemConfiguration -framework QuartzCore -framework iAd -lsqlite3 -lz -framework MapKit -framework CoreLocation -framework AVFoundation -framework AddressBook -framework MessageUI -framework AudioToolbox -framework Foundation -framework UIKit -framework CoreGraphics -lGoogleAdMobAds -o /Users/Samuel/Library/Developer/Xcode/DerivedData/Funny_Maths-ctillajbcxujxhdywykbwodfufrw/Build/Products/Debug-iphonesimulator/reactionfree.app/reactionfree
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_Reachability", referenced from:
objc-class-ref in RssFunViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
where the stuff in bold, underline and italics is the stuff in red in the error log, and hence the name of the bug. I've no idea what's going on - something I've done wrong with my frameworks and architecture settings maybe? Any help is much appreciated, Thanks in advance, Sam |
|
|
|
0
|
|
|
#2 |
|
Don't you need alot more frameworks? not sure, but that might be a good start to look at.
Also for the newer versions of Xcode, you need to import this to supress a warning. Code:
#import <netinet/in.h>
__________________
CSS (Counter Strike Source) Tribute - iPad application ![]() iPad Mini, iPad 4, iPad 2, iPhone 3G,4,5, iMac 24", Mac Mini Last gen, Macbook Pro with Dell U2711
|
|
|
|
0
|
|
|
#3 |
|
Apparently Reachability.m isn't being compiled. Is it in your project and in your Target? Can you see it being compiled in the build log?
|
|
|
|
1
|
|
|
#4 |
|
Thanks jnoxx for the import stuff, though I had the same frameworks as Apple in their example project.
Thanks PhoneyDeveloper - I just hadn't added that reachability.m to the build target - that's a new feature of Xcode isn't it, where it doesn't add it automatically? Sam |
|
|
|
0
|
|
|
#5 |
|
Yeah, something funky going on here. Seems Xcode no longer remembers to carry over the "Add to targets" checkbox settings. I thought in the past it would set it to what it was the last time you added some files. I can't seem to get it to stay checked anymore. Xcode bug, perhaps?
__________________
|
|
|
|
0
|
|
|
#6 |
|
Yeah - I've had that bug before - just forgot to check that this time. It is odd of Apple to leave it like that though - it's fairly well documented how annoying it is...
|
|
|
|
0
|
![]() |
|
| Tags |
| error, ios, programming, reachability, sdk |
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 03:25 AM.








I support the 
Linear Mode
