-->

iOS 5.1 Reachability

2020-08-01 05:23发布

问题:

I am trying to use Reachability in ios 5.1 but it gives me a Match-o Linker error. I am using Xcode 4.3 and building my app with armv6 and armv7. I have read that Reachability doesn't play nice with armv7, which may be causing the error. Is that true? If so, is ythere any workaround to get my app checking internet connectivity? And yes, i have imported both

Reachability.h

and

SystemConfiguration.framework

My sample implementation code is as below:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];    
internetReachable = [Reachability reachabilityForInternetConnection];
[internetReachable startNotifier];    
hostReachable = [Reachability reachabilityWithHostName: @"www.apple.com"];
[hostReachable startNotifier];

Thanks in advcance!

回答1:

https://github.com/tonymillion/Reachability

iOS5 / GCD / ARC friendly version



回答2:

Not sure whether you have solved this problem yet.

But if you read the actual error highlighted in Xcode 4 and if it says something like

"ld: duplicate symbol _OBJC_IVAR_$_Reachability.reachabilityRef in . . . linker command failed with exit code 1 (use -v to see invocation)"

That is saying you have already included Reachability.h and Reachability.m in your project somewhere and you now have included a duplicate copy.

Delete all the duplicate copies of Reachability.h and Reachability.m and leave just 1 copy of it somewhere in your project files.