GPS testing with .gpx file

21 December 2018
For faster development

Sometimes, your app needs more than just accessing the current location.

For example, you want to watch the location over time, whether to show it on the map or other features than make use of the location.

We can provide a current location for the simulator, however, we can't provide a lists of locations that showing the movement of the app over time with the default simulator settings.

Luckily for us, as developer, we are able to mock the locations of the app using .gpx file.

How it works

.gpx is a format to save GPS data. Basically it contains latitude, longitude and the timestamps at which the points are at.

A simple .gpx file looks like this.

<?xml version="1.0"?>
<gpx version="1.1" creator="">
<wpt lat="3.109193" lon="101.461774">
<wpt lat="3.109562" lon="101.461968">
<wpt lat="3.109193" lon="101.461774">

When you have that file, add it to your xcode, and you will be able to use the coordinates in your simulator with a toggle.


So for my case, I am having 3 different paths I created for development and testing purpose. Each of them in its own .gpx file.

Select any one, and the simulator will pick up the location and changes over time.


Now you have different coordinates as time passes returned from the simulator to test.