简体   繁体   English

Apple Mach-O Linker (Id) 可达性错误

[英]Apple Mach-O Linker (Id) Error with Reachability

I keep getting this error when I try to build my project which uses reachability (the error only came up after I tried to implement reachability):当我尝试构建使用可达性的项目时,我不断收到此错误(错误仅在我尝试实现可达性后出现):在此处输入图像描述

I read some other posts on the inte.net but nothing seemed to work.我在 inte.net 上阅读了一些其他帖子,但似乎没有任何效果。 I added SystemConfiguration.framework (project, build phases, +), but that didn't work (I had already added it when the error came up).我添加了 SystemConfiguration.framework(项目、构建阶段、+),但这没有用(出现错误时我已经添加了它)。 Here's how I implement the files:以下是我如何实现这些文件:

#import <UIKit/UIKit.h>
#import "Reachability.h"

@interface catalogDetailView : UIViewController{

}

-(void)checkNetwork;

@end

Then in the.m:然后在.m中:

#import "catalogDetailView.h"
-(void)checkNetwork{
    if ([self reachable]) {
        NSLog(@"Connected to Network");
    }
    else {
        NSLog(@"Connection Failed");
    }
}
-(BOOL)reachable {
    Reachability *r = [Reachability reachabilityWithHostName:@"apple.com"];
    NetworkStatus internetStatus = [r currentReachabilityStatus];
    if(internetStatus == NotReachable) {
        return NO;
    }
    return YES;
}

So if you could help that would be amazing;!因此,如果您能提供帮助,那就太棒了;! Thanks ;) Luke谢谢 ;) 卢克

You need to add Reachability.m to your target's "Compile Sources" build phase.您需要将Reachability.m添加到目标的“编译源”构建阶段。

One way to do it:一种方法:

  1. Select Reachability.m in the project navigator, on the left side of the Xcode window. If you don't see it, choose the menu View > Navigators > Show Project Navigator. Select Reachability.m在project navigator中,左边是Xcode window。如果没有看到,选择菜单View > Navigators > Show Project Navigator。
  2. Show the file inspector on the right side of the Xcode window. View > Utilities > Show File Inspector.在Xcode window右侧显示文件检查器。View > Utilities > Show File Inspector。
  3. In the Target Membership section, check the checkbox next to your target.在 Target Membership 部分,选中目标旁边的复选框。

I'll bet you that your 'compile sources list' does not contain reachability.m .我敢打赌你的“编译源列表”不包含reachability.m Drag it in under the build phases tab to the list.将它拖到构建阶段选项卡下的列表中。 I often find that when adding files to a project, Xcode often doesn't add the files your target's compile list (because the default is to not add them).我经常发现,在向项目添加文件时,Xcode 经常不添加目标编译列表中的文件(因为默认是不添加它们)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM