开发者

Need Reachability version for ARC in iOS5

开发者 https://www.devze.com 2023-04-13 09:44 出处:网络
Using Apple\'s Reachability code in iOS5 I get a bunch of compilation errors as shown below. Any ideas on what is happening here? I\'m using ARC so I have edited the standard code slightly to remove a

Using Apple's Reachability code in iOS5 I get a bunch of compilation errors as shown below. Any ideas on what is happening here? I'm using ARC so I have edited the standard code slightly to remove autorelease/retain and the NSAutoReleasePool.

Undefined symbols for architecture armv7:

"_SCNetworkReachabilityCreateWithAddress", referenced from: +[Reachability reachabilityWithAddress:] in Reachability.o

"_SCNetworkReachabilityCreateWithName", referenced from: +[Reachability reachabilityWithHostName:] in Reachability.o

"_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from: -[Reachability stopNotifier] in Reachability.o

"_SCNetworkReachabilityScheduleWithRunLoop", referenced from: -[Reachability startNotifier] in Reachability.o

"_SCNetworkReachabilitySetCallback", referenced from: -[Reachability startNotifier] in Reachability.o

"_SCNetworkReachabilityGetFlags", referenced from: -[Reachability connectionRequired] in Reachability.o -[Reachability currentReachabilityStatus] in Reachability.o

ld: symbol(s) not found for architecture armv7 clang: error: link开发者_运维技巧er command failed with exit code 1 (use -v to see invocation)

Does anyone have workable Reachability code for ARC under iOS5?


I wrote a clean 'drop in' version of reachability for ARC and iOS5 - you can get it here: https://github.com/tonymillion/Reachability


You don't really need an ARC version of Reachability, just simply disable ARC for reachability file(s)

Disable ARC on MULTIPLE files:

  • Select desired files at Target/Build Phases/Compile Sources in Xcode
  • PRESS ENTER
  • Type -fno-objc-arc
  • Press Enter or Done

You also have a missing framework. Add SystemConfiguration framework.


I rearranged them for IOS 5 and arc they are working tested

Please DON'T FORGET TO ADD SystemConfiguration.framework on your project


I just found this that might help. Thank the author for this (this is not mine)!

https://gist.github.com/1182373


Apple's reachability has been updated to version 3 which now supports ARC iOS5+

Here is the link to the sample by Apple


You need to add the systemConfiguration.framework to make Reachability work.


I know this thread is old, but in case anyone is interested you can solve this by disabling ARC for Reachability.m. Look at this post.


Tony, is your class correctly work even with a non ARC project? I can see lot ok Reachability: dealloc in my consolle, and I don't know if it's normal or not! I use this method to check the connection (is the only place where I user Rechability)

-(BOOL)checkConnection{
    BOOL connessione = FALSE;
    Reachability *wifiResouce       = [[Reachability reachabilityForLocalWiFi] retain];
    Reachability *phoneResouce      = [[Reachability reachabilityForInternetConnection] retain];

    NetworkStatus netStatusWiFi     = [wifiResouce currentReachabilityStatus];
    NetworkStatus netStatusPhone    = [phoneResouce currentReachabilityStatus];
    if(netStatusWiFi == NotReachable){
        if(netStatusPhone == ReachableViaWWAN){
            connessione = TRUE;
        }
    }else if(netStatusWiFi == ReachableViaWiFi){
        connessione = TRUE;
    }
    [phoneResouce release];
    [wifiResouce release];
    return connessione; 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号