GPS testing with .gpx file

21 December 2018
For faster development
gps

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="gpxgenerator.com">
<wpt lat="3.109193" lon="101.461774">
    <ele>7.00</ele>
    <time>2018-01-04T08:08:05Z</time>
</wpt>
<wpt lat="3.109562" lon="101.461968">
    <ele>7.00</ele>
    <time>2018-01-04T08:08:20Z</time>
</wpt>
<wpt lat="3.109193" lon="101.461774">
    <ele>6.96</ele>
    <time>2018-01-04T08:08:35Z</time>
</wpt>
</gpx>

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.

demo

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.


End

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