iphone - 从苹果复制了可达性测试,但链接器失败

标签 iphone cocoa reachability

我尝试使用苹果发布的可达性项目来检测自己示例中的可达性。我复制了大部分初始化,但我在链接器中遇到此失败:

Ld build/switchViews.build/Debug-iphoneos/test.build/Objects-normal/armv6/test normal armv6
cd /Users/uid04100/Documents/TEST
setenv IPHONEOS_DEPLOYMENT_TARGET 3.1.3
setenv PATH  "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk -L/Users/uid04100/Documents/TEST/build/Debug-iphoneos -F/Users/uid04100/Documents/TEST/build/Debug-iphoneos -filelist /Users/uid04100/Documents/TEST/build/switchViews.build/Debug-iphoneos/test.build/Objects-normal/armv6/test.LinkFileList -dead_strip -miphoneos-version-min=3.1.3 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/uid04100/Documents/TEST/build/switchViews.build/Debug-iphoneos/test.build/Objects-normal/armv6/test

Undefined symbols:
"_SCNetworkReachabilitySetCallback", referenced from: -[Reachability startNotifer] in Reachability.o
"_SCNetworkReachabilityCreateWithAddress", referenced from: +[Reachability reachabilityWithAddress:] in Reachability.o
"_SCNetworkReachabilityScheduleWithRunLoop", referenced from: -[Reachability startNotifer] in Reachability.o
"_SCNetworkReachabilityGetFlags", referenced from: -[Reachability connectionRequired] in Reachability.o -[Reachability currentReachabilityStatus] in Reachability.o
"_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from: -[Reachability stopNotifer] in Reachability.o
"_SCNetworkReachabilityCreateWithName", referenced from: +[Reachability reachabilityWithHostName:] in Reachability.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

我的委托(delegate).h:

#import <UIKit/UIKit.h>

@class Reachability;

@interface testAppDelegate : NSObject
<UIApplicationDelegate> {  UIWindow
*window;  UINavigationController *navigationController;

 Reachability* hostReach;
 Reachability* internetReach;
 Reachability* wifiReach;

}

@property (nonatomic, retain) IBOutlet
UIWindow *window; @property
(nonatomic, retain) IBOutlet
UINavigationController
*navigationController;

@end

我的代表.m:

#import "testAppDelegate.h"

#import "SecondViewController.h"
#import "Reachability.h"

@implementation testAppDelegate



@synthesize window; @synthesize
navigationController;

- (void) updateInterfaceWithReachability:
(Reachability*) curReach {
    if(curReach == hostReach)  {
        BOOL connectionRequired= [curReach connectionRequired];


        if(connectionRequired)
        { //in these brackets schould be some code with sense, if i´m getting it to run
        }
        else
        {
        }

    }  if(curReach == internetReach)  {   }  if(curReach == wifiReach)  { 
 }   }

//Called by Reachability whenever
status changes.
- (void) reachabilityChanged: (NSNotification* )note {
 Reachability* curReach = [note
object];  NSParameterAssert([curReach
isKindOfClass: [Reachability class]]);
 [self
updateInterfaceWithReachability:
curReach]; }


- (void)applicationDidFinishLaunching:(UIApplication
*)application {    
    // Override point for customization after application launch
   // Observe the
kNetworkReachabilityChangedNotification.
When that notification is posted, the
    // method "reachabilityChanged" will be called.  //   
[[NSNotificationCenter defaultCenter]
addObserver: self selector:
@selector(reachabilityChanged:) name:
kReachabilityChangedNotification
object: nil];

    //Change the host name here to change the server your monitoring
 hostReach = [[Reachability
reachabilityWithHostName:
@"www.apple.com"] retain];  [hostReach
startNotifer];  [self
updateInterfaceWithReachability:
hostReach];

    internetReach = [[Reachability reachabilityForInternetConnection]
retain];  [internetReach
startNotifer];  [self
updateInterfaceWithReachability:
internetReach];

    wifiReach = [[Reachability reachabilityForLocalWiFi] retain];
 [wifiReach startNotifer];  [self
updateInterfaceWithReachability:wifiReach];
     [window addSubview:[navigationController
view]];
    [window makeKeyAndVisible]; }


- (void)dealloc {  [navigationController release];
    [window release];
    [super dealloc]; }


@end

最佳答案

算了。我只是不知道我必须手动添加系统配置框架。我以为导入的时候就加上了。

关于iphone - 从苹果复制了可达性测试,但链接器失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2788354/

相关文章:

iphone - Xcode 4.5 : NSLayoutConstraint issue in iphone 5. 1 模拟器

iphone - 什么时候在实例变量前加上下划线?

Cocoa - 捕获 NSStatusItem 鼠标悬停事件

ios - iOS8 的可达性问题

ios - CoreTelephony 因 : Received a notification with no notification name 原因崩溃

iphone - [mapView addOverlay :overlayPolygon]; 时,集合在枚举时发生了变异

iphone - 为什么这张图片没有添加到我的 ScrollView 中?

ios - iOS App Store收据,文件不存在

objective-c - 应用程序在未启用垃圾收集的情况下崩溃

iPhone SDKreachabilityWithAddress问题