Errors in WhereAmI project


#1

I have typed the code exactly as in the book and am getting errors which I am unsure how to resolve. Any help is appreciated.

WhereAMIViewController.h

[code]
//
// whereAmIViewController.h
// whereAmI
//
// Created by Kane McGukin on 5/19/13.
// Copyright © 2013 Kane McGukin. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>

@interface whereAmIViewController : UIViewController
{
CLLocationManager *locationManager;
}

@end[/code]

WhereAmIViewController.m

//
//  whereAmIViewController.m
//  whereAmI
//
//  Created by Kane McGukin on 5/19/13.
//  Copyright (c) 2013 Kane McGukin. All rights reserved.
//

#import "whereAmIViewController.h"


@implementation whereAmIViewController

-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    
    if(self)
    {
        //Create location manager objec
        locationManager = [[CLLocationManager alloc] init];
        
        //And we want it to be as accurate as possible
        //regardless of how much time/power it takes
        [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
        
        //Tell our location manager to start looking for it's location immediately
        [locationManager startUpdatingLocation];
    }
    
    return self;
}
@end

Errors:
Apple Mach-O linker error:
Undefined symbols for architecture i386:

  1. OBJC_CLASS$_CLLocationManager”, referenced from:
    objc-class-ref in whereAmIViewController.o
  2. “_kCLLocationAccuracyBest”, referenced from:
    -[whereAmIViewController initWithNibName:bundle:] in whereAmIViewController.o
    ld: symbol(s) not found for architecture i386
    clang:
  3. error: linker command failed with exit code 1 (use -v to see invocation)

#2

Looks like you haven’t added the CoreLocation.framework to the project.

Add the framework and build again.


#3

Thanks. I did drag the framework into the project, but I guess I did it wrong. I will do it again.


#4

The problem was there was a second copy. I had deleted my first attempt and created a second project under the same name in the same folder. This caused there to be two copies of coreLocation group.