Using FakeGPSUtility to Debug Location Change in Apps
From sports to city guides — many apps now deal with location and heading-related events. Testing those apps is quite a tricky process, as it doesn’t matter how well you test it at your current location if you are going to offer it to users worldwide. Don’t panic, there’s a better way to debug location change, for example, only in Honolulu than relying on vague bug reports from Hawaiian users. To lessen this burden, we’ve made FakeGPSUtility, an instrument that allows you to replace data for the CLLocationManager with custom parameters.
How to Install
There are two ways to install FakeGPSUtility from GitHub: either manually or from CocoaPods.
- Drag the FakeGPSUtility folder into your Xcode project.
- Define ‘DEBUG’ in target build configuration.
- Add MapKit and CoreLocation frameworks into your target.
- Enter in your *.pod file: pod ‘FakeGPSUtility’, :git =>
- Define ‘DEBUG’ in the target build configuration.
That’s all there is to it. Now you’re ready to test various user locations in your app.
To run this utility on an Apple device, complete the handshake, then press the “Simulate Location” button. On the next screen, you will see a map and can configure the tool and stop/pause/resume simulation for custom locations.
The utility settings offer three modes (starting with iOS 7.0 there are four modes) of simulation:
- Single — allows choosing one point on the map whose location the tool will simulate;
- Multiple — offers choosing several points on the map for simulating location;
- File — uses points from a *.plist file, so there is no need to set them manually. To use this mode, add a Ponits.plist file to the app sources;
- Route — allows choosing two points with a long-press gesture and creates a route between them. Simulation of coordinate changes will be made along this new route. Besides, you can define the value for updates of route coordinates per second and loop a route. This mode is available for only iOS 7.
After you have configured this tool, close the menu and continue debugging your application.
I hope I have convinced you that setting a custom current location does not have to be a chore. With the right tool, it can be relatively easy.