iOS Location Simulation Testing

Kranthi Kiran Reddy K
Life360 Engineering
4 min readApr 29, 2021

Overview

Life360 is the leading family safety platform and offers consumers one easy to use app to access a variety of features to protect their loved ones. The app is simple to use, but it is actually a complex app with location-heavy features like driver reports, geo-fence violations, and location-based offers.

To test these features Life360 Test Engineering team has to actually take a drive to check that we’re updating the location accurately and be in a specific region to verify that location-based features are displayed, But this can take a lot of time and this can be a challenge while testing US features by a remote offshore team.

To solve this bottleneck and expand our location testing to the offshore team we came up with a location simulation tool to simulate our mobile apps and enable our global team.

This tool helped us to change content dynamically based on simulated location and display features. Unlike Android(Fake GPS), We don’t have apps to simulate location on iOS in Appstore. We can do this using Xcode. While there are other methods, Xcode does not require wiping the device and can be used with the latest version of iOS.

The following steps assume that you have Xcode on your Mac. While you can set location easily using the Simulator, Xcode provides much more powerful tools for setting custom locations.

iOS Setup instructions

There are two sections to simulate the user location for apps that have native views and also In-app web views. For these, you need the below tools.

  • VPN — for features that use reverse IP lookup
  • Xcode app — for physical location simulation

VPN

For simulating In-app web pages we need VPN to simulate the location of the device itself but native apps will not show VPN location. So we have to use a combination of VPN and Xcode. To do that you would first need to download any VPN app on iPhone from the App Store and Select any US-based server (To Update the Zipcode to the US).

Xcode

As we don't want to change the Life360 app’s code itself on how it gets the location and also more importantly interfere with the core location code. We took an approach to build a new app that actually simulates the entire device’s location.

Please follow the below steps to create an app that can simulate the location you specify.

Create an apple developer account for signing the below location simulating app

  1. Download Xcode and Launch

2. Click on Create a new Xcode project

3. Select App and click on Next

4. Provide the below details and Click Next
a. Unique Product Name. Ex: l360.location.test
b. Add apple developer account from Team dropdown
c. Unique Organization Identifier (any name)

5. Save the project by Clicking create

6. Connect iPhone to the MAC and Select your device

7. Click on Build / Play Button

Note: When building an app for 1st time you see the below error because we need to trust the certificate on the device & again Click on Build in Xcode

To Trust the Certificate:
Open iPhone Device Settings > General. > Profile & Device management > Select the Development Profile with your Team ID > Trust

8. Once the build is successful, the app is launched on the device

9. Now, to simulate location.

Xcode > Debug > Simulate Location > Select Location (Ex: San Francisco)

10. Now we are ready to test the app we wanna test, launch Life360 and test away.

NOTE: Do not close the location simulating app on iPhone/Simulator. The app should run in the device background for the Location to work

VIDEO ON HOW THE LOCATION SIMULATING WORKS

The below video shows the initial location in India and after following the above process, the location is updated to the US

Come join us

Life360 is creating the largest membership service for families by developing technology that helps managing family life easier and safer. There is so much more to do as we get there and we’re looking for talented people to join the team: check out our jobs page.

--

--