Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6/iOS 8 Location Simulation doesn't work

I've just updated to Xcode 6/iOS 8 SDK and my location service simulation in simulator started not working. It was fine before I updated (I'm currently unable to test on real device). Now, when I select a location for simulation, nothing happens. Delegate's -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations method is not called. I've restarted Xcode, cleaned the build folder, nothing changed. Why can this happen?

like image 615
Can Poyrazoğlu Avatar asked Sep 19 '14 13:09

Can Poyrazoğlu


2 Answers

Since IOS 8 you need to ask for authorization before starting the CLLocationManager.

Are you calling one of these methods?

[self.locationManager requestWhenInUseAuthorization];  // For foreground access
[self.locationManager requestAlwaysAuthorization]; // For background access

If you have created the project before XCode 6, you probably also need to add the info.plist entry for the new permission.

For more details have a look at this post: Location Services not working in iOS 8

like image 175
Prine Avatar answered Oct 06 '22 07:10

Prine


Add Below code in your method

if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) 
{
    [self.locationManager requestWhenInUseAuthorization];
}

Also add Below line at your info.plist file

Key:NSLocationWhenInUseUsageDescription value:Uses current location

like image 32
NaveenReddy Avatar answered Oct 06 '22 06:10

NaveenReddy