Xcode offers a handy feature for developers that are working with location services. Simulating a Location at Runtime allows the developer to specify a location that the device will report to apps as they run. You can even use prerecorded GPX files to simulate walking, running, biking or driving along a route to see how the location changes are handled by your app.
Simulating location changes in apps that have been terminated is a bit trickier, as the debug area option to simulate location is only available when you're debugging a process.
To work around this, follow these steps:
- Run the app in which you want to simulate a background location change.
- Stop the app.
- Create a dummy project - I just use the single view application template.
- Run the dummy project on the same device.
- In the debug bar for the dummy project, choose a location, or add a GPX file containing the location changes you want to simulate to your project and choose it.
Even though the app that you're wanting to simulate a background location change on was stopped at step 2, you should see it get a location services update via application:didFinishLaunchingWithOptions:.
The UIApplicationLaunchOptionsLocationKey should be set in the options dictionary. You can do this from the comfort of your desk without needing to take your iPhone to the location you want to test in.