2011-02-11 6 views
8

He estado trabajando en esta aplicación para iPhone por un tiempo, y la tuve completamente terminada y funcionando. El proyecto en el que estaba expandiendo fue descargado de un repositorio de subversión en línea que mi profesor me había dado acceso también. Accidentalmente no descargué la copia "raíz" o algo así, así que no pude realizar ningún cambio en el repositorio. Con la ayuda de mis instructores, descargué la copia de raíz hoy y agregué todos mis archivos de clase a ella para poder confirmar los cambios. Sin embargo, ahora estoy recibiendo 3 errores extraños que nunca he visto antes:Referencia de la clase Objective-C: Símbolos no encontrados Error

símbolos no definidos:

"_OBJC_CLASS _ $ _ mapListViewController", referencia desde: clase objc-ref-a-mapListViewController en mapViewController.o

"_OBJC_CLASS _ $ _ mapParser", referenciado desde: clase objc-ref-a-mapParser en mapViewController.o

"_OBJC_CLASS _ $ _ mapTabViewController", referencia desde: clase objc-ref-a-mapTabViewController en mapViewController.o

ld: Símbolo (s) que no se encuentra collect2: ld devuelto 1 código de salida

Ese es el mensaje de error exacto que recibo. No he cambiado ningún código de la versión que funcionaba completamente esta mañana. ¿Algún consejo? El archivo mapViewController parece ser lo que está causando el problema, por lo que aquí es así:

#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

revisar mi respuesta He resuelto este problema [aquí] (http://stackoverflow.com/questions/2931457/iphone-sdk-linking-errors-with-static-library/ 12276904 # 12276904) – swiftBoy

Respuesta

29

más probable es que estas tres clases faltan en el archivo de proyecto. Compruebe el grupo Clases en su proyecto XCode para ver si estos tres archivos están presentes. De lo contrario, haga clic con el botón derecho en el grupo Clases y haga clic en Agregar> Archivos existentes para agregarlos.

Si los archivos se agregan al proyecto, asegúrese de que los archivos de implementación (.m) de estas clases faltantes se agreguen a las fuentes compiladas. Para verificar eso, expanda el grupo Targets > your application target > Compile Sources y vea si los archivos están presentes. De lo contrario, haga clic derecho en "Compilar fuentes" y vaya al Add > Existing Files para agregarlos. Una forma alternativa y quizás más rápida de hacer lo mismo es seleccionar los archivos .m para cada una de las clases que faltan, y ver si la casilla de verificación Bulls Eye en el extremo derecho está marcada. De lo contrario, compruébalo y se agregará automáticamente a las fuentes compiladas.

+2

mientras que eso no era exactamente lo que estaba mal, me guiaste en la dirección correcta = D. Ya tenía los archivos de clase agregados, pero en la lista de clases hay una fila de casillas de verificación, y los cuadros de esas clases no se marcaron. Ni siquiera sabía que existía hasta ahora, lol ... ¡gracias por la ayuda! – ReCon11

+0

perfecto. me alegra que estés listo para comenzar a codificar :). para el bien de la compleción y para otros usuarios que puedan tener el mismo problema, actualizaré esta respuesta. – Anurag

1

que estaba teniendo el mismo problema que he resuelto añadiendo el marco en xCode

+0

Hice exactamente lo contrario y funcionó para mí. No estoy seguro de cómo Xcode viene con estos errores ... :) – penatheboss

0

cuando se agrega CoreGraphics libraray.you que seleccionar project_name-> objetivos/seleccione el nombre del proyecto (no seleccione nombre de la prueba proyecto, su una de error que se enfrenta) -> buildsetting-> y agrega CoreLocation.framework

0

"_OBJC_CLASS _ $ _ mapListViewController", hace referencia a partir de: objc de clase-ref-a-mapListViewController en mapViewController.o

"_OBJC_CLASS_ $ _mapParser ", referencia ced desde: objc-class-ref-to-mapParser en mapViewController.O

"_OBJC_CLASS _ $ _ mapTabViewController", hace referencia a partir de: clase objc-ref-a-mapTabViewController en mapViewController.o

ld: Símbolo (s) no encontrado collect2: ld devolvió 1 código de salida

Asegúrese de que todos (mapListViewController, mapParser, mapTabViewController) tienen tanto @interface & @implementation

esta solucionar mi problema. me paso echar de menos mirar @implementation was missing

Cuestiones relacionadas