12

I am using a Custom Location under Debug --> Location --> Custom Location

While this setting does work just fine for me, the simulator frequently changes my setting from Custom Location to None. This reverting does not appear to have a pattern as I may run the same project 5 or 10 times without the setting reverting. Other times it changes the Location to None every 1 or 2 times I run the simulator.

Is there a way to lock the setting in so I do not have to fight with it?

2 Answers 2

25

Have you tried setting a default location? May be it is set to none.

Edit your scheme > Select "Run XXXX.app / Debug" > Select "Allow Location Simulation" and select a default location.

2
  • 1
    Nice! And you can create your location file using something like gpx-poi.com May 5, 2014 at 1:14
  • Really great tip! I especially like the gpx-poi.com generated Location-file, which comes in very handy for doing some UnitTests.
    – iOS-Coder
    Jan 20, 2015 at 13:18
13

The accepted answer it is a solution, solved your problem, but for other developers that are facing this issue, there is also a easier solution where you don't need a GPX file or to select one of the locations provided as default:

  1. In your Xcode go to Product > Scheme > Edit Scheme...
  2. In the Run projectName/ Debug, go to Options and Deselect "Allow Location Simulation".. yes uncheck it!
  3. Press OK

How your scheme should appear

  1. Run your app in the simulator
  2. On simulator menu choose Debug > Location > Custom Location
  3. Specify latitude/longitude coordinates

Simulator location

Now the simulator will keep this as default location. Actually the Allow Location Simulation on Xcode, together with the option none is the reason for "forgetting" the location you added before.

From now on, your simulator will always remember the last custom location!

2
  • 1
    This really saved some annoying resetting of the iOS-Simulator location for me. Also a nasty bug (depending on your Keyboard setting) where the decimal symbol "," versus "." gave me the wrong Lat/Lon-values is solved in this way. Thanks for the great tip @Roberto!
    – iOS-Coder
    Jan 20, 2015 at 13:22
  • This is the more useful answer for use in the simulator. If you set "allow location simulation" in the scheme and set a default, it affects not only the simulator but also when the app is installed on a device, which I find not helpful. Turning that setting off allows you to set the location in the simulator without being reset to "None" every time you launch the app.
    – Paul King
    Jun 20, 2018 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.