Question

Je travaille sur cette application iPhone depuis un certain temps maintenant, et je l'ai complètement terminée et je travaillais. Le projet sur lequel je me détendais a été téléchargé à partir d'un référentiel de subversion en ligne que mon professeur m'avait également donné accès. Je n'ai pas accidentellement téléchargé la copie "root" ou quelque chose comme ça, donc je n'ai pas pu commettre de modifications dans le référentiel. Avec l'aide de mon instructeurs, j'ai téléchargé la copie root aujourd'hui et ajouté tous mes fichiers de classe afin que je puisse commettre les modifications. Cependant, je reçois maintenant 3 erreurs étranges que je n'ai jamais vues auparavant:

Symboles non définis:

"_Objc_class _ $ _ MapListViewController", référencé à partir de: Objc-Class-Ref-MapListViewController dans MapViewController.O

"_Objc_class _ $ _ Mapparser", référencé à partir de: objc-class-ref-to-mapparser dans MapViewController.o

"_Objc_class _ $ _ MaptabViewController", référencé à partir de: objc-class-ref-maptabViewController dans mapViewController.o

LD: Symbole (s) introuvable Collect2: LD RETOUR

C'est le message d'erreur exact que je reçois. Je n'ai changé aucun code de la version qui fonctionnait complètement plus tôt ce matin. Aucun conseil? Le fichier MapViewController semble être ce qui cause le problème, alors voici également:

#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
Était-ce utile?

La solution

Très probablement, ces trois classes sont absents de votre fichier de projet. Vérifiez le groupe de classes dans votre projet Xcode pour voir si ces trois fichiers sont présents. Sinon, cliquez avec le bouton droit sur le groupe Classes, puis cliquez sur Ajouter> Fichiers existants pour les ajouter.

Si les fichiers sont ajoutés au projet, assurez-vous que les fichiers d'implémentation (.m) pour ces classes manquants sont ajoutés aux sources compilées. Pour vérifier cela, développez le groupe Targets > your application target > Compile Sources, et voyez si les fichiers sont présents. Sinon, cliquez avec le bouton droit sur "Compiler les sources" et GOTO Add > Existing Files pour les ajouter. Une alternative et peut-être plus rapide de faire la même chose est de sélectionner les fichiers .m pour chacune des classes manquantes, et de voir si la case à cocher Bulls Eye à l'extrême droite est cochée. Sinon, vérifiez-le et il sera automatiquement ajouté aux sources compilées.

Autres conseils

"_Objc_class _ $ _ MapListViewController", référencé à partir de: Objc-Class-Ref-MapListViewController dans MapViewController.O

"_Objc_class _ $ _ Mapparser", référencé à partir de: objc-class-ref-to-mapparser dans MapViewController.o

"_Objc_class _ $ _ MaptabViewController", référencé à partir de: objc-class-ref-maptabViewController dans mapViewController.o

LD: Symbole (s) introuvable Collect2: LD RETOUR

Assurez-vous que tous (MapListViewController, Mapparser, MaptabViewController) ont à la fois @Interface & @Implementation

Cela résout mon problème. Il me arrive de manquer look @implementation manquait

J'avais le même problème que j'ai résolu en ajoutant le cadre dans Xcode

Lorsque vous ajoutez Coregraphics Libraray.Vous devez sélectionner Project_Name-> Targets / Sélectionner Nom du projet (pas sélectionner le nom du test du projet, c'est une erreur que vous êtes confronté) -> BuildSetting-> et ajouter CoreLocation.Framework

J'avais ce problème quand j'essayais d'avoir pod 'FirebaseRemoteConfig Extensions de l'application intérieures. J'ai ajouté $(inherited) à la place de -ObjC à Autres drapeaux de linker dans les paramètres de construction de la cible d'extension.

enter image description here

J'espère que cela aide n'importe qui là-bas. J'ai perdu 1 heure pour trouver cette solution.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top