Search code examples
iphoneobjective-ccxcodereachability

Error when trying to check for internet access with Reachable.h/.m


I have imported Reachable and followed the chosen anser on this thread: Reachability Guide for iOS 4 Everything looks good, apart from a yellow triangle saying "incomplete implementation". Then when I press run I get ten red errors coming from the Reachable.m file, saying things like "ARC forbids explicit message send of release', 'NSAutoReleasePool is unavailable in automatic counting reference mode' and 'Cast of C pointer of type 'void ': to objective-c pointer type 'Reachability' etc. and 'declaration of 'struct sockaddr_in' will not be visible outside of this function [3]' from the Reachable.h file. Any ideas? Maybe the Reachable files are out of date? I have no experience with using C data types etc. and whenever I have to import an extra implementation/header file things seem to go wrong :/.


Solution

  • Apple's Reachability sample code was last updated in 2010. It doesn't use ARC and contains code that is non-trivial to convert to ARC.

    The solution is simple:

    Set the -fno-objc-arc compiler flag for that file.

    Compiler -fno-obj-arc flag set for Reachability.m