copied the reachability-test from apple, but the linker gives a failure
Asked Answered
O

1

7

i have tried to use the reachability-project published by apple to detect a reachability in an own example. i copied the most initialization, but i get this failure in the linker:

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

my 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

my delegate.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
Ovi answered 7/5, 2010 at 12:5 Comment(0)
O
18

Forget it. I just didn't know that I have to add the systemconfiguration-framework manually. I thought it would be added when it was imported.

Ovi answered 7/5, 2010 at 12:15 Comment(2)
You don't import frameworks; you import headers. Importing a header into a source file does not add a framework to the project or to the target, as you've seen.Dendriform
Yes, adding SystemConfiguration.framework will solve the problem.Unwilled

© 2022 - 2024 — McMap. All rights reserved.