Simulating other locations with Xcode

I initially discovered that there were more icons other than the ones I could find in the Nashville area simply by moving around large cities like New York and San Francisco in the Maps app. But even after finding new location categories, because Apple limits Spotlight location results to places that are nearby, searching for these places in Spotlight produced no results. After a bit of digging I stumbled across Nick Arnott’s post Using Xcode to Test Location Services, and realized I could take this approach to trick my iOS device into thinking that I was traveling the world from the cozy comfort of my desk.

If you are an iOS developer and have Xcode installed, all you need to do is create a new iOS Application Project (I created a Single View Application named Locations), set your application’s Location to your connected iOS device, and build and run your new app on your device. Once the application is built and running on your iPhone or iPad, go to the Debug menu in Xcode on your computer and select the Simulate Location option. Within Simulate Location, you will find a set of twelve default locations provided by Apple to choose from.

Once you select one of these locations, open the Maps app on your iOS device and tap the Current Location icon in the bottom left hand corner to confirm that your device has properly applied your simulated location. If everything checks out correctly in Maps, you can go back to the Springboard and start searching within Spotlight now for locations near your simulated city.

You can add additional locations in Xcode as well. If you want to add your own locations, you’ll need to create a GPX (GPS Exchange Format) file for each new location and associate these files with your Project. You can do this by creating a GPX file in your text editor of choice, naming it with the .gpx file extension, and then adding it via the “Add GPX File to Project…” option under Debug>Simulate Location in Xcode or be creating a new Empty File in your project in Xcode and naming the file with the .gpx extension and adding the GPX file info.

The GPX file itself is pretty straight forward and looks like this:

<gpx> <wpt lat="33.3250" lon="44.4220"></wpt> </gpx>

The unique info you’ll need for each location is its latitude and longitude, and you’ll need to adjust the lat and lon numbers listed above for each new GPX location file you create. I used gps-coordinates.net to find the coordinates I needed, but there are several ways to look up a locations latitude and longitude.