Need Reachability version for ARC in iOS5

2019-03-09 16:18发布

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: linker command failed with exit code 1 (use -v to see invocation)

Does anyone have workable Reachability code for ARC under iOS5?

8条回答
ゆ 、 Hurt°
2楼-- · 2019-03-09 17:01

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

Here is the link to the sample by Apple

查看更多
萌系小妹纸
3楼-- · 2019-03-09 17:02

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.

查看更多
我命由我不由天
4楼-- · 2019-03-09 17:02

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; 
}
查看更多
Deceive 欺骗
5楼-- · 2019-03-09 17:16

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

查看更多
SAY GOODBYE
6楼-- · 2019-03-09 17:18

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

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

查看更多
够拽才男人
7楼-- · 2019-03-09 17:21

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.

查看更多
登录 后发表回答