iOS8 - Simulator - How to get Locations simulated

2019-03-06 03:54发布

问题:

My App tracks your location. With iOS8 I had to change how it was starting location services. I got this working with

[self.locationManager requestAlwaysAuthorization];

and adding NSLocationAlwaysUsageDescription to the plist file.

The app now gets your location when run on a device, but not in the simulator.

Any clues on how to get this to work in the simulator? It used to!!!

回答1:

In the iOS Simulator, select Debug > Location, then choose your location.



回答2:

I decided to post this in case anyone else had the same issue. I got the simulator to respond to location changes again by adding NSLocationWhenInUseUsageDescription back into the plist file. I had removed it since my app needs the Always permission instead of WhenInUse. By adding this back to the plist the simulator is now happy. I did not have this issue on the physical device, just the simulator.