Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 2, 2012, 01:30 PM   #1
gwelmarten
macrumors 6502
 
Join Date: Jan 2011
Location: England!
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);
}
And then when I want to check if I am connected to the internet, I call this:
Code:
if(![self connected])
    {
        // not connected    
    } else
    {
        // connected, do some internet stuff 
    }
Unfortunately, when I build, I get the following two errors:

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
gwelmarten is offline   0 Reply With Quote
Old Apr 2, 2012, 05:17 PM   #2
jnoxx
macrumors 65816
 
jnoxx's Avatar
 
Join Date: Dec 2010
Location: Aartselaar // Antwerp // Belgium
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>
__________________

iPad Mini, iPad 4, iPad 2, iPhone 3G,4,5, iMac 24", Mac Mini Last gen, Macbook Pro Retina with Dell U2711
jnoxx is offline   0 Reply With Quote
Old Apr 2, 2012, 06:23 PM   #3
PhoneyDeveloper
macrumors 68020
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
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?
PhoneyDeveloper is offline   1 Reply With Quote
Old Apr 3, 2012, 11:02 AM   #4
gwelmarten
Thread Starter
macrumors 6502
 
Join Date: Jan 2011
Location: England!
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
gwelmarten is offline   0 Reply With Quote
Old Apr 3, 2012, 12:11 PM   #5
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by gwelmarten View Post
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?
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?
__________________
dejo is offline   0 Reply With Quote
Old Apr 5, 2012, 11:59 AM   #6
gwelmarten
Thread Starter
macrumors 6502
 
Join Date: Jan 2011
Location: England!
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...
gwelmarten is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Tags
error, ios, programming, reachability, sdk

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:36 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC