iOS5 中需要 ARC 的可达性版本
在 iOS5 中使用 Apple 的 Reachability 代码时,我收到一堆编译错误,如下所示。对这里发生的事情有什么想法吗?我使用的是 ARC,因此我稍微编辑了标准代码以删除 autorelease/retain
和 NSAutoReleasePool
。
架构armv7的未定义符号:
“_SCNetworkReachabilityCreateWithAddress”,引用自: +[ReachabilityreachabilityWithAddress:]在Reachability.o
“_SCNetworkReachabilityCreateWithName”,引用自: +[ReachabilityreachabilityWithHostName:]在Reachability.o
“_SCNetworkReachabilityUnscheduleFromRunLoop”,引用自: -Reachability.o 中的[Reachability stopNotifier]
“_SCNetworkReachabilityScheduleWithRunLoop”,引用自: -Reachability.o 中的[Reachability startNotifier]
“_SCNetworkReachabilitySetCallback”,引用自: -Reachability.o 中的[Reachability startNotifier]
“_SCNetworkReachabilityGetFlags”,引用自: -Reachability.o 中的[Reachability 连接必需] -Reachability.o 中的[Reachability currentReachabilityStatus]
ld:找不到架构armv7 clang的符号:错误:链接器 命令失败,退出代码为 1(使用 -v 查看调用)
有谁有 iOS5 下 ARC 的可用可达性代码吗?
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.old: 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我为 ARC 和 iOS5 编写了一个干净的“直接”版本的可达性 - 您可以在这里获取它:https://github.com/tonymillion/可达性
I wrote a clean 'drop in' version of reachability for ARC and iOS5 - you can get it here: https://github.com/tonymillion/Reachability
您实际上并不需要 ARC 版本的 Reachability,只需对可达性文件禁用 ARC
在多个文件上禁用 ARC:
您还缺少框架。添加系统配置框架。
You don't really need an ARC version of Reachability, just simply disable ARC for reachability file(s)
Disable ARC on MULTIPLE files:
You also have a missing framework. Add SystemConfiguration framework.
我针对 IOS 5 重新排列了它们,它们正在测试中
请不要忘记添加 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
我刚刚发现这个可能有帮助。感谢作者(这不是我的)!
https://gist.github.com/1182373
I just found this that might help. Thank the author for this (this is not mine)!
https://gist.github.com/1182373
Apple 的可达性已更新到版本 3,现在支持 ARC iOS5+
这是 Apple 提供的示例的链接
Apple's reachability has been updated to version 3 which now supports ARC iOS5+
Here is the link to the sample by Apple
您需要添加 systemConfiguration.framework 才能使 Reachability 发挥作用。
You need to add the systemConfiguration.framework to make Reachability work.
我知道这个线程很旧,但如果有人感兴趣,您可以通过禁用 Reachability.m 的 ARC 来解决这个问题。 看看这篇文章 。
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,即使在非 ARC 项目中,您的课程也能正常工作吗?
我可以在控制台中看到很多Reachability: dealloc,但我不知道这是否正常!
我使用这种方法来检查连接(这是我使用 Rechability 的唯一地方)
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)