Reachability giving errors during compile...

Discussion in 'iOS Programming' started by ArtOfWarfare, Dec 24, 2011.

  1. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #1
    I'm using Reachability.h/m in my project to determine whether or not the user has a network connection.

    It was initially complaining about ARC, so I turned off ARC for the file, and that got rid of about half the errors, but it's still giving me errors about

    "Apple Mach-O Linker (Id) Error"

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

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    These are linker errors. You've forgotten to add the framework that has those symbols in it.
     
  3. ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #3
    Oh!

    Thank you! I copied and pasted reachability from one project to another but forgot to make sure all the frameworks were there. Thanks!
     
  4. North Bronson macrumors 6502

    Joined:
    Oct 31, 2007
    Location:
    San José
    #4
    Are you using Reachability only to determine if a network connection exists?

    Try connecting to the network and downloading whatever resource your application is interested in. The NSURLConnection APIs will give you an error if the connection fails. That error will tell you if there was no network connection.

    This is going to be more efficient than using Reachability in your application. Reachability is useful some of the time. It is not a good idea if your only goal is to find out if a connection exists.
     
  5. ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #5
    I'm using it before sending a request to Apple's servers information on items available for In-App Purchase... if I simply sent it and didn't get a response, that wouldn't say whether the issue was a lack of a connection or a failure elsewhere.
     
  6. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #6
    Actually, the recommended strategy is to attempt to send the request. If it fails then check reachability. If the answer is "not reachable" then present that error to the user. Otherwise present the error that you received from your attempted request to the user.
     
  7. ArtOfWarfare, Dec 26, 2011
    Last edited: Dec 26, 2011

    ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #7
    I guess that makes sense.

    I have a bigger issue though right now... my code is still not compiling and is still giving me the same errors as before. "SystemConfiguration.framework" has been added to my list of Frameworks, I've cleaned, restarted Xcode, and attempted to run, but got the same exact errors. Suggestions?

    I'm noticing a warning
    Edit: Alright, I've got it working now.

    The issue was the method I'd used to add the framework. The proper way of doing it was to go to the target, click on the build phases tab, and then add it to the list labeled "Link Binary With Libraries" (using the + button in the bottom corner.)
     

Share This Page