iOS5 中需要 ARC 的可达性版本

发布于 2024-12-10 09:40:30 字数 1066 浏览 1 评论 0原文

在 iOS5 中使用 Apple 的 Reachability 代码时,我收到一堆编译错误,如下所示。对这里发生的事情有什么想法吗?我使用的是 ARC,因此我稍微编辑了标准代码以删除 autorelease/retainNSAutoReleasePool

架构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.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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

静若繁花 2024-12-17 09:40:30

我为 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

嘿嘿嘿 2024-12-17 09:40:30

您实际上并不需要 ARC 版本的 Reachability,只需对可达性文件禁用 ARC

在多个文件上禁用 ARC

  • 在目标/构建阶段选择所需的文件 /Compile Sources in Xcode
  • PRESS ENTER
  • Type -fno-objc-arc
  • Press Enter or Done

您还缺少框架。添加系统配置框架

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.

雨巷深深 2024-12-17 09:40:30

针对 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

等风也等你 2024-12-17 09:40:30

我刚刚发现这个可能有帮助。感谢作者(这不是我的)!

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

卷耳 2024-12-17 09:40:30

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

染年凉城似染瑾 2024-12-17 09:40:30

您需要添加 systemConfiguration.framework 才能使 Reachability 发挥作用。

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

烙印 2024-12-17 09:40:30

我知道这个线程很旧,但如果有人感兴趣,您可以通过禁用 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.

皇甫轩 2024-12-17 09:40:30

Tony,即使在非 ARC 项目中,您的课程也能正常工作吗?
我可以在控制台中看到很多Reachability: dealloc,但我不知道这是否正常!
我使用这种方法来检查连接(这是我使用 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; 
}

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; 
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文