Home » Ios » Accidentally overwrote iPhone device location via Xcode

Accidentally overwrote iPhone device location via Xcode

Posted by: admin February 24, 2018 Leave a comment

Questions:

So I’m working on a location-based iPhone app. I’m mainly testing on the iOS simulator, and as such using the Core Location Simulation. All good – I can pretend to be in New York or San Francisco or wherever.

Then I move to testing my app on my iPhone, with that checkbox still enabled. I go for a walk (in, like, the actual real world), pull out Google Maps, and realise that my actual, not-simulator iPhone is using a simulated location. In this instance my iPhone is stuck thinking that it’s in London (where I live), but right central in Picadilly Circus, not where I am.

I get home, open up Xcode, and to make sure I’ve nailed down the cause (rather than just a weird GPS bug etc), change the ‘default location’ to Johannesburg. Unplug my phone, open Google Maps (and Foursquare, to be sure), same deal. Stuck in Johannesburg.

So it’s definitely this panel here that’s borked my phone, but I can’t figure out how to reset it.

Things I’ve tried that don’t seem to work:

  • changing ‘default location’ to ‘none’ & rerunning
  • disabling ‘allow location simulation’ & rerunning

So it seems once you’ve given your iPhone an arbitrary location to pretend to be in, just disabling that doesn’t fix it.

Location Simulation

Any ideas? I’m going travelling in a few days and really need my GPS to work!

Answers:

This has happened to me before, it was very strange and mysterious!

I don’t remember how I fixed it, but: have you tried Reset Location & Privacy in the Settings app? If all else fails, I suspect Reset All Settings would maybe work.

As I try to remember, I think maybe hard rebooting the phone might also work (just turn it off, turn it back on).

Questions:
Answers:

While you have your device connected to the debugger there is a little button at the top of the debug panel. Right here:

enter image description here

Click on that and you can select ‘don’t simulate location’, exit the app, and I think you’ll be good to go.

I’m a little foggy too on how that relates to the location defined in the scheme and the location set in the simulator. I usually find it easier to set a location in the simulator itself rather than in the scheme (at least when testing in the simulator is possible) to avoid issues like this. In the simulator if you enter a location under ‘Debug > Location > Custom Location…’ while the simulator is on the springboard the location will persist between launches of the app and the simulator.

Questions:
Answers:

just Reset Location & Privacy . turnoff location service . restart your phone .. turn on location service . try using google maps .. it work for me ..

Questions:
Answers:

The important step is the hard reset after resetting location settings. Not sure if you need to do anything in Xcode, but it is a good idea to select ‘Don’t simulate location’

Questions:
Answers:

Goto Settings>Privacy>Location Services. Turn-Off Location Services. Restart the phone. Open Google maps. A popup will come to enable location service, click on the options given that will take you directly to Settings. If popup didn’t appear in Google Maps, click on Mylocation button at the bottom. Enable Location services and get back to Google Maps. It re-enabled the real Location for me.

Questions:
Answers:

Go back to Xcode (or whatever coding software you are using) and rerun the application, then select don’t simulate location.