2011-02-11 7 views
8

Ho lavorato a questa app per iPhone per un po 'di tempo e l'ho terminato completamente e funzionante. Il progetto su cui stavo espandendo è stato scaricato da un repository di sovversione online che il mio professore mi aveva dato anche accesso. Per sbaglio non ho scaricato la copia "root" o qualcosa del genere, quindi non sono stato in grado di commettere alcuna modifica al repository. Con l'aiuto dei miei istruttori, ho scaricato la copia radice oggi e ho aggiunto tutti i miei file di classe su di esso in modo da poter commettere le modifiche. Tuttavia, ora sto ottenendo 3 strani errori che non ho mai visto prima:Riferimento classe Objective-C: errore simboli non trovato

simboli non definiti:

"_OBJC_CLASS _ $ _ mapListViewController", riferimento dal: objc-class-ref-to-mapListViewController in mapViewController.o

"_OBJC_CLASS _ $ _ mapParser", riferimento da: objc-class-ref-to-mapParser in mapViewController.o

"_OBJC_CLASS _ $ _ mapTabViewController", riferimento da: objc-class-ref-to-mapTabViewController in mapViewController.o

LD: il simbolo (s) non trovato collect2: ld returned 1 exit status

Questo è l'esatto messaggio di errore che sto ricevendo. Non ho cambiato alcun codice dalla versione che stava funzionando completamente all'inizio di questa mattina. Qualche consiglio? Il file mapViewController sembra essere quello che causa il problema, ecco che così:

#import "mapViewController.h" 
#import "locationDetailViewController.h" 
#import "DPUAnnotation.h" 
#import "mapParser.h" 
#import "mapListViewController.h" 
#import "mapTabViewController.h" 

@implementation mapViewController 
@synthesize locationManager, mapView, mapAnnotations, mParser, mapListView, tabView; 

@class DPUAnnotation; 

+ (CGFloat)annotationPadding; 
{ 
    return 10.0f; 
} 
+ (CGFloat)calloutHeight; 
{ 
    return 40.0f; 
} 

- (void)gotoLocation 
{ 
    // start off by default at DePauw campus 
    MKCoordinateRegion newRegion; 
    newRegion.center.latitude = 39.639348; 
    newRegion.center.longitude = -86.861231; 
    newRegion.span.latitudeDelta = 0.006776; 
    newRegion.span.longitudeDelta = 0.006291; 

    [self.mapView setRegion:newRegion animated:YES]; 
} 

- (void)viewDidLoad { 

    self.title = @"Map"; 
    mapView.mapType = MKMapTypeHybrid; 
    mapView.showsUserLocation = YES; 

    mapListView = [[mapListViewController alloc] initWithNibName:@"mapListView" bundle:nil]; 
    tabView = [[mapTabViewController alloc] initWithNibName:@"mapTabViewController" bundle:nil]; 

    if (mapAnnotations == nil) 
    { 
     self.mapAnnotations = [NSMutableArray array]; 
    } 
    else 
    { 
     [mapAnnotations removeAllObjects]; 
    } 

    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"btn_home.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(mainpageClicked)]; 
    [self.navigationItem setLeftBarButtonItem:backButton]; 

    UIBarButtonItem *mapListButton = [[UIBarButtonItem alloc] initWithTitle:@"Building List" style:UIBarButtonItemStylePlain target:self action:@selector(pushMapList)]; 
    [self.navigationItem setRightBarButtonItem: mapListButton]; 

    locationManager = [[CLLocationManager alloc] init]; 
    locationManager.delegate = self; 
    locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
    [locationManager startUpdatingLocation]; 

    [self gotoLocation]; 

    self.mParser = [[[mapParser alloc] init] autorelease]; 
    self.mParser.delegate = self; 
    [self.mParser start]; 

    [super viewDidLoad]; 
} 

- (void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:(BOOL)animated]; 
} 

- (void)dealloc 
{ 
    [mapView release]; 
    [locationManager release]; 
    [mapAnnotations release]; 

    [super dealloc]; 
} 

/* 
* Returns the User to the main Application Page 
*/ 
- (IBAction)mainpageClicked 
{ 
    NSLog(@"Return To Main page Clicked"); 
    [self.parentViewController dismissModalViewControllerAnimated:YES]; 
    [self.navigationController release]; 
} 

- (IBAction) pushMapList 
{ 
    tabView = [[mapTabViewController alloc] initWithNibName:@"mapTabViewController" bundle:nil]; 
    tabView.mapAnnotations2 = mapAnnotations; 
    [self.navigationController pushViewController:tabView animated:YES]; 
    [tabView release]; 
} 

- (IBAction)addAnnotation 
{ 
    [self.mapView removeAnnotations:self.mapView.annotations]; 

    for (int i = 0; i < [mapAnnotations count]; i++) 
     [mapView addAnnotation:[mapAnnotations objectAtIndex:i]]; 
    NSLog(@"BLAH BLAH BLAH PLEASE PRINT"); 
    if([mapAnnotations count] == 0) 
     NSLog(@"array is empty"); 
} 

- (void)showDetails:(id)sender 
{ 
    NSInteger selectedIndex = [sender tag]; 
    DPUAnnotation *selectedObject = [mapAnnotations objectAtIndex:selectedIndex]; 

    [self.navigationController setToolbarHidden:YES animated:NO]; 

    NSURL *url = [NSURL URLWithString: selectedObject.url]; 

    locationDetailViewController *locationDetailView; 
    locationDetailView = [[locationDetailViewController alloc] initWithNibName:@"mapDetailView" bundle:nil]; 
    [self.navigationController pushViewController:locationDetailView animated:YES]; 
    [locationDetailView.webView loadRequest: [NSURLRequest requestWithURL:url]]; 
    [locationDetailView release]; 

    [selectedObject release]; 
} 

- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
    // if it's the user location, just return nil. 
    if ([annotation isKindOfClass:[MKUserLocation class]]) 
     return nil; 

    if([[annotation subtitle] isEqualToString:@"Academic"]) 
    { 
     // try to dequeue an existing pin view first 
     static NSString* annotationIdentifier = @"annotationIdentifier"; 
     MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier]; 

     if (!pinView) 
     { 
      MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation 
                      reuseIdentifier:annotationIdentifier] autorelease]; 
      annotationView.canShowCallout = YES; 

      UIImage *academicImage = [UIImage imageNamed:@"academic.png"]; 

      CGRect resizeRect; 

      resizeRect.size = academicImage.size; 
      CGSize maxSize = CGRectInset(self.view.bounds, 
             [mapViewController annotationPadding], 
             [mapViewController annotationPadding]).size; 
      maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight]; 
      if (resizeRect.size.width > maxSize.width) 
       resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height/resizeRect.size.width * maxSize.width); 
      if (resizeRect.size.height > maxSize.height) 
       resizeRect.size = CGSizeMake(resizeRect.size.width/resizeRect.size.height * maxSize.height, maxSize.height); 

      resizeRect.origin = (CGPoint){0.0f, 0.0f}; 
      UIGraphicsBeginImageContext(resizeRect.size); 
      [academicImage drawInRect:resizeRect]; 
      UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext(); 
      UIGraphicsEndImageContext(); 

      annotationView.image = resizedImage; 
      annotationView.opaque = NO; 

      UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
      NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation]; 
      rightButton.tag = annotationValue; 
      [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside]; 
      annotationView.rightCalloutAccessoryView = rightButton; 

      return annotationView; 
     } 
     else 
     { 
      pinView.annotation = annotation; 
     } 
     return pinView; 
    } 

    else if([[annotation subtitle] isEqualToString:@"Administrative"]) 
    { 
     // try to dequeue an existing pin view first 
     static NSString* annotationIdentifier = @"annotationIdentifier"; 
     MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier]; 

     if (!pinView) 
     { 
      MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation 
                      reuseIdentifier:annotationIdentifier] autorelease]; 
      annotationView.canShowCallout = YES; 

      UIImage *administrativeImage = [UIImage imageNamed:@"administrative.png"]; 

      CGRect resizeRect; 

      resizeRect.size = administrativeImage.size; 
      CGSize maxSize = CGRectInset(self.view.bounds, 
             [mapViewController annotationPadding], 
             [mapViewController annotationPadding]).size; 
      maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight]; 
      if (resizeRect.size.width > maxSize.width) 
       resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height/resizeRect.size.width * maxSize.width); 
      if (resizeRect.size.height > maxSize.height) 
       resizeRect.size = CGSizeMake(resizeRect.size.width/resizeRect.size.height * maxSize.height, maxSize.height); 

      resizeRect.origin = (CGPoint){0.0f, 0.0f}; 
      UIGraphicsBeginImageContext(resizeRect.size); 
      [administrativeImage drawInRect:resizeRect]; 
      UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext(); 
      UIGraphicsEndImageContext(); 

      annotationView.image = resizedImage; 
      annotationView.opaque = NO; 

      UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
      NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation]; 
      rightButton.tag = annotationValue; 
      [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside]; 
      annotationView.rightCalloutAccessoryView = rightButton; 

      return annotationView; 
     } 
     else 
     { 
      pinView.annotation = annotation; 
     } 
     return pinView; 
    } 

    else if([[annotation subtitle] isEqualToString:@"University Housing"] || [[annotation subtitle] isEqualToString:@"Residence Halls"] || [[annotation subtitle] isEqualToString:@"University Duplexes"] || [[annotation subtitle] isEqualToString:@"Greek Housing"]) 
    { 
     // try to dequeue an existing pin view first 
     static NSString* annotationIdentifier = @"annotationIdentifier"; 
     MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier]; 

     if (!pinView) 
     { 
      MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation 
                      reuseIdentifier:annotationIdentifier] autorelease]; 
      annotationView.canShowCallout = YES; 

      UIImage *housingImage = [UIImage imageNamed:@"housing.png"]; 

      CGRect resizeRect; 

      resizeRect.size = housingImage.size; 
      CGSize maxSize = CGRectInset(self.view.bounds, 
             [mapViewController annotationPadding], 
             [mapViewController annotationPadding]).size; 
      maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight]; 
      if (resizeRect.size.width > maxSize.width) 
       resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height/resizeRect.size.width * maxSize.width); 
      if (resizeRect.size.height > maxSize.height) 
       resizeRect.size = CGSizeMake(resizeRect.size.width/resizeRect.size.height * maxSize.height, maxSize.height); 

      resizeRect.origin = (CGPoint){0.0f, 0.0f}; 
      UIGraphicsBeginImageContext(resizeRect.size); 
      [housingImage drawInRect:resizeRect]; 
      UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext(); 
      UIGraphicsEndImageContext(); 

      annotationView.image = resizedImage; 
      annotationView.opaque = NO; 

      UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
      NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation]; 
      rightButton.tag = annotationValue; 
      [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside]; 
      annotationView.rightCalloutAccessoryView = rightButton; 

      return annotationView; 
     } 
     else 
     { 
      pinView.annotation = annotation; 
     } 
     return pinView; 
    } 

    else if([[annotation subtitle] isEqualToString:@"Other"]) 
    { 
     // try to dequeue an existing pin view first 
     static NSString* annotationIdentifier = @"annotationIdentifier"; 
     MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier]; 

     if (!pinView) 
     { 
      MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation 
                      reuseIdentifier:annotationIdentifier] autorelease]; 
      annotationView.canShowCallout = YES; 

      UIImage *otherImage = [UIImage imageNamed:@"other.png"]; 

      CGRect resizeRect; 

      resizeRect.size = otherImage.size; 
      CGSize maxSize = CGRectInset(self.view.bounds, 
             [mapViewController annotationPadding], 
             [mapViewController annotationPadding]).size; 
      maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight]; 
      if (resizeRect.size.width > maxSize.width) 
       resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height/resizeRect.size.width * maxSize.width); 
      if (resizeRect.size.height > maxSize.height) 
       resizeRect.size = CGSizeMake(resizeRect.size.width/resizeRect.size.height * maxSize.height, maxSize.height); 

      resizeRect.origin = (CGPoint){0.0f, 0.0f}; 
      UIGraphicsBeginImageContext(resizeRect.size); 
      [otherImage drawInRect:resizeRect]; 
      UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext(); 
      UIGraphicsEndImageContext(); 

      annotationView.image = resizedImage; 
      annotationView.opaque = NO; 

      UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
      NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation]; 
      rightButton.tag = annotationValue; 
      [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside]; 
      annotationView.rightCalloutAccessoryView = rightButton; 

      return annotationView; 
     } 
     else 
     { 
      pinView.annotation = annotation; 
     } 
     return pinView; 
    } 

    else if([[annotation subtitle] isEqualToString:@"Fields"]) 
    { 
     // try to dequeue an existing pin view first 
     static NSString* annotationIdentifier = @"annotationIdentifier"; 
     MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier]; 

     if (!pinView) 
     { 
      MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation 
                      reuseIdentifier:annotationIdentifier] autorelease]; 
      annotationView.canShowCallout = YES; 

      UIImage *athleticsImage = [UIImage imageNamed:@"athletics.png"]; 

      CGRect resizeRect; 

      resizeRect.size = athleticsImage.size; 
      CGSize maxSize = CGRectInset(self.view.bounds, 
             [mapViewController annotationPadding], 
             [mapViewController annotationPadding]).size; 
      maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight]; 
      if (resizeRect.size.width > maxSize.width) 
       resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height/resizeRect.size.width * maxSize.width); 
      if (resizeRect.size.height > maxSize.height) 
       resizeRect.size = CGSizeMake(resizeRect.size.width/resizeRect.size.height * maxSize.height, maxSize.height); 

      resizeRect.origin = (CGPoint){0.0f, 0.0f}; 
      UIGraphicsBeginImageContext(resizeRect.size); 
      [athleticsImage drawInRect:resizeRect]; 
      UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext(); 
      UIGraphicsEndImageContext(); 

      annotationView.image = resizedImage; 
      annotationView.opaque = NO; 

      UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
      NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation]; 
      rightButton.tag = annotationValue; 
      [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside]; 
      annotationView.rightCalloutAccessoryView = rightButton; 

      return annotationView; 
     } 
     else 
     { 
      pinView.annotation = annotation; 
     } 
     return pinView; 
    } 

    else if([[annotation subtitle] isEqualToString:@"Landmarks"]) 
    { 
     // try to dequeue an existing pin view first 
     static NSString* annotationIdentifier = @"annotationIdentifier"; 
     MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier]; 

     if (!pinView) 
     { 
      MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation 
                      reuseIdentifier:annotationIdentifier] autorelease]; 
      annotationView.canShowCallout = YES; 

      UIImage *landmarkImage = [UIImage imageNamed:@"landmark.png"]; 

      CGRect resizeRect; 

      resizeRect.size = landmarkImage.size; 
      CGSize maxSize = CGRectInset(self.view.bounds, 
             [mapViewController annotationPadding], 
             [mapViewController annotationPadding]).size; 
      maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight]; 
      if (resizeRect.size.width > maxSize.width) 
       resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height/resizeRect.size.width * maxSize.width); 
      if (resizeRect.size.height > maxSize.height) 
       resizeRect.size = CGSizeMake(resizeRect.size.width/resizeRect.size.height * maxSize.height, maxSize.height); 

      resizeRect.origin = (CGPoint){0.0f, 0.0f}; 
      UIGraphicsBeginImageContext(resizeRect.size); 
      [landmarkImage drawInRect:resizeRect]; 
      UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext(); 
      UIGraphicsEndImageContext(); 

      annotationView.image = resizedImage; 
      annotationView.opaque = NO; 

      UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
      NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation]; 
      rightButton.tag = annotationValue; 
      [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside]; 
      annotationView.rightCalloutAccessoryView = rightButton; 

      return annotationView; 
     } 
     else 
     { 
      pinView.annotation = annotation; 
     } 
     return pinView; 
    } 

    return nil; 
} 

#pragma mark <mapParser> Implementation 

- (void)parser:(NSXMLParser *)parser didFailWithError:(NSError *)parseError { 

} 

- (void)parserDidEndParsingData:(mapParser *)parser 
{ 
    [self addAnnotation]; 

    tabView.mapAnnotations2 = mapAnnotations; 

    self.mParser = nil; 
    [mParser release]; 
} 

- (void)parser:(mapParser *)parser didParseItem:(NSArray *)parsedItem 
{ 
    NSLog(@"Did Parse Map Item"); 

    [self.mapAnnotations addObjectsFromArray:parsedItem]; 
} 

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {} 
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {} 

@end 
+0

controlla la mia risposta Ho risolto questo problema [qui] (http://stackoverflow.com/questions/2931457/iphone-sdk-linking-errors-with-static-library/ 12276904 # 12276904) – swiftBoy

risposta

29

Molto probabilmente queste tre classi sono mancanti dal file di progetto. Controlla il gruppo Classi nel tuo progetto XCode per vedere se questi tre file sono presenti. In caso contrario, fare clic con il pulsante destro del mouse sul gruppo Classi e fare clic su Aggiungi> File esistenti per aggiungerli.

Se i file vengono aggiunti al progetto, assicurarsi che i file di implementazione (.m) per queste classi mancanti vengano aggiunti alle origini compilate. Per verificare che, espandere il gruppo Targets > your application target > Compile Sources e vedere se i file sono presenti. In caso contrario, fai clic con il pulsante destro del mouse su "Compila origini" e vai a Add > Existing Files per aggiungerli. Un modo alternativo e forse più veloce per fare lo stesso è selezionare i file .m per ciascuna delle classi mancanti, e vedere se la casella di controllo dell'occhio toro all'estrema destra è selezionata. In caso contrario, verificarlo e verrà automaticamente aggiunto a Origini compilate.

+2

mentre quello non era esattamente ciò che era sbagliato, mi hai condotto nella giusta direzione = D. Avevo già aggiunto i file di classe, ma nell'elenco delle classi è presente una riga di destinazione di caselle di controllo e le caselle per quelle classi erano deselezionate. Non sapevo nemmeno che esistesse fino ad ora lol ... grazie per l'aiuto! – ReCon11

+0

perfetto. contento che sia tutto pronto per iniziare la codifica :). per completezza e altri utenti che potrebbero avere lo stesso problema, aggiornerò questa risposta. – Anurag

1

ho avuto lo stesso problema che ho risolto con l'aggiunta del quadro nel xCode

+0

Ho fatto l'esatto opposto e ha funzionato per me. Non sei sicuro di come Xcode stia arrivando con questi errori ... :) – penatheboss

0

quando si aggiunge CoreGraphics libraray.you necessario selezionare project_name-> bersagli/select nome del progetto (non selezionare il nome di test del progetto, il suo un errore che si faccia) -> buildsetting-> e aggiungere CoreLocation.framework

0

"_OBJC_CLASS _ $ _ mapListViewController", si fa riferimento da: objc-class-ref-to-mapListViewController in mapViewController.o

"_OBJC_CLASS_ $ _mapParser ", referen ced da: objc-class-ref-to-mapParser in mapViewController.o

"_OBJC_CLASS _ $ _ mapTabViewController", si fa riferimento da: objc-class-ref-to-mapTabViewController in mapViewController.o

LD: il simbolo (s) non trovato collect2: ld returned 1 exit status

assicurarsi che tutti (mapListViewController, mapParser, mapTabViewController) hanno entrambi @interface & @implementation

questo risolvere il mio problema. Mi manca il look @ mancava l'implementazione