I cannot get even the simplest location updating code to work. I have a location app that worked fine for over a year, and now when I try to compile and run it (after upgrading to xcode 6.1 and with no changes to the code), after calling startUpdatingLocation, the didUpdateLocations callback never fires, and I can see that the gps indicator never appears next to the battery indicator as it should. I have started a new test project that does nothing but attempts to register for location updates, and still the same results: no location updates on device or simulator. Here is the code for the single view controller of the test project:
//ViewController.h
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface ViewController : UIViewController <CLLocationManagerDelegate>
{
}
@property (strong, nonatomic) CLLocationManager* locationManager;
@end
//ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.locationManager = [[CLLocationManager alloc]init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[self.locationManager requestWhenInUseAuthorization];
[self.locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"got a location");
}
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"Error: %@",error.description);
}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
NSLog(@"got a location");
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end
It would be fantastic if someone with the latest version of xcode could create a project like this that does nothing but receive location updates, verify that it works, and post the code in full. I have tried adding things to the plist file and all other remedies from similar questions to no avail.