Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

Location Simulation in Xcode’s Simulator

Location Simulation is a critical feature for apps that provide location access. You want to mimic the environment of real users without stepping in your car and driving a route while debugging. Whether you want to simulate switching directly between two places or an entire route of waypoints: both are possible in Xcode’s Simulator.

Earlier, we discussed increasing productivity by testing Push Notifications on the Simulator. We can gain a similar productivity boost by configuring a fake location inside Xcode’s Simulator.

Simulate a location via Xcode

Xcode provides a Simulate Location menu with a few common places to pick from:

Xcode provides an option for Location Simulation with a few familiar places.
Xcode provides an option for Location Simulation with a few familiar places.

You can find this menu inside the console header, providing you access to simulate the location of a few familiar places like San Francisco and London. You can tap “Don’t Simulate Location” to reset the simulation.

Before diving into GPS Exchange, I first want to highlight another way of simulating the location in Xcode.

Using a scheme configuration to simulate a location

Changing the location on every run manually is inefficient and can become repetitive. We can solve this by configuring a simulated location from within the scheme configuration:

The scheme configuration offers a similar menu but will automatically apply the location on launch.
The scheme configuration offers a similar menu but will automatically apply the location on launch.

The configured location will be simulated whenever you launch your app using the scheme.

Stay updated with the latest in Swift & SwiftUI

The 2nd largest newsletter in the Apple development community with 18,551 developers. Don't miss out – Join today:


Location Simulation using GPS Exchange

The provided list of familiar places is a great start, but it doesn’t come with the flexibility of simulating routes. A common way to solve this problem is by using so-called GPX files. GPX stands for GPS Exchange Format, an XML Schema designed as a standard GPS data format for software applications like Xcode.

Tools like gpxgenerator.com allow you to select individual waypoints and export them as a GPX file. You can load this file into Xcode using the “Add GPS Exchange to Project…” option.

While GPX files work great, you might find it annoying to collect those waypoints manually. Therefore, I developed a solution that allows you to simply specify a start and destination location.

Simulating freeway drive and walking routes

Each of Xcode’s provided simulation options requires you to manually configure one of the provided locations or select a GPX file whenever you want to simulate the location. While it works, it doesn’t allow you to stay in your flow.

Using RocketSim, you can configure quick actions for any location, freeway drive, or walking route:

RocketSim gives you quick access to any custom location or route.
RocketSim gives you quick access to any custom location or route.

RocketSim calculates individual waypoints and uses MapKit underneath to ensure locations match the official Apple Maps output. Both freeway drive and walking routes can be used with any given start and end location. The autocompletion makes it effortless to find the location you need:

RocketSim allows you to simulate any custom place.
RocketSim allows you to simulate any custom place.

You can test individual custom locations apart from routes and test the configuration before saving if you have a Simulator open. In the above example, testing is disabled due to not having any Simulator windows open.

Simulating routes with different speeds and intervals

A route simulation has configuration options for speed, distance, and seconds. The latter two define how often a location update is pushed, while the speed determines how fast the ‘car is driving.’

You can control both speed and interval for any custom route.
You can control both speed and interval for any custom route.

Switching locations quickly

The great thing of using locations in RocketSim is the fact that you can access them directly from the side panel:

You can access any of your locations directly next to the Xcode Simulator.
You can access any of your locations directly next to the Xcode Simulator.

If you don’t have any locations configured yet, you can pick any location using the Select button:

Pick any solution using the select location popover window.
Pick any solution using the select location popover window.

Or pick any of the location scenarios for quick access to typical location simulations:

Simulate scenarios like a city run or bicycle ride.
Simulate location scenarios like a city run or bicycle ride.

Conclusion

Location Simulation is essential when working on an app with location access. Whether jumping from one place to another or simulating routes, being able to test these quickly drastically speeds up your workflow. Xcode provides a few basic simulation options, but RocketSim allows you to save common scenarios and activate simulation quickly.

If you like to improve your workflow, even more, check out the workflow category page. Feel free to contact me or tweet to me on Twitter if you have any additional tips or feedback.

Thanks!