Most of the time if you use the Core Location services in the iOS simulator it will default to Cupertino, but there are times that it will give you a kCLErrorDomain code of 0, or you may want a different location for testing. It turns out that if you edit the run scheme of your project, you can choose whether to allow location simulation and there is a drop down of predefined locations.
But what if you want a location that isn’t in the list? It turns out that there is an option for adding a GPX file to the workspace. Just get the latitude and longitude of the location you want to use (Google Maps is good for this). Then head over to GPS Visualizer. Plug in your data and ask for a GPX format file as shown below:
You definitely need the “header” lines in the “paste your data here” box, otherwise the service doesn’t know what your data means. For the example above, I used OPI’s home city of Minneapolis, Minnesota.
Now you can choose to import this file from the Options panel in Edit Schemes and presto! You can now test your application in the simulator and have it give you the current location you want.
As a bonus, here’s the GPX file for Minneapolis. Enjoy!
<?xml version="1.0"?> <gpx creator="GPS Visualizer http://www.gpsvisualizer.com/" version="1.1" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"> <wpt lat="44.9833" lon="-93.2667"> <name>Minneapolis, MN</name> <desc>Minneapolis, MN</desc> </wpt> </gpx>