Infinite Loop

Testing Location Based iPhone Apps

One of the challenges that iPhone App developers are often faced with is how to properly test location based Apps. The iPhone simulator only provides you with the location of Apple’s headquarters in Cupertino, or alternatively the location of your own development computer. If your App’s content is based on the current location of the user, then it’s very difficult to get anywhere close to some real-world tests without having to travel around with your iPhone. Unless the content is only based in your own neighborhood it will quickly become both very time consuming and costly.

I was recently faced with the same dilemma during development of a new (still undisclosed) App until I discovered this little gem: FTLocationSimulator from FutureTap. It’s a small class that replaces some of the functionality of CLLocationManager. Instead of feeding your code the actually location of the user, it instead grabs fake locations from a KML file generated using Google Earth.

[AdSense - blog banner]In order to use the Core Location simulator in your own projects you first need to head over to GitHub and grab a copy of the code. Once downloaded, you add the files to your project in Xcode and insert the following snippet instead of your normal initialization of CLLocationManager:

     [FTLocationSimulator sharedInstance].mapView =;
     [FTLocationSimulator sharedInstance].delegate = self;
     [[FTLocationSimulator sharedInstance] startUpdatingLocation];
     self.locationManager = [[[CLLocationManager alloc] init] autorelease];
     self.locationManager.delegate = self;
     [self.locationManager startUpdatingLocation];

You need to set up a few other settings in your project, but these are all described in details in the readme file that’s part of the download so I’ll skip them here.

Once everything is set up you need to fire up Google Earth and define the path you want to simulate in your App. Save the new path as a KML file in a convenient location on your computer.

In Xcode you then double-click on your executable file and select the “Arguments” tab in the Info window. Click on the “+” button under the section called “Arguments to be passed on launch”. This will allow you to specify which KML file to use for your test by specifying -FakeLocationsRoute <KML_FILE_PATH>:

It is possible to specify more than one test file as shown above so you can quickly switch between different test routes. However only one file at a time will be used by the Core Location simulator.

It is also possible to override the default location update by specifying the launch argument  -FakeLocationsUpdateInterval <INTERVAL_IN_SECONDS>.

Hopefully, when you now launch your App in the simulator you should now see your location being updated along the route you defined in Google Earth.

Comments (11) | Trackback

11 Responses to “Testing Location Based iPhone Apps”

  1. [...] This post was mentioned on Twitter by Claus Broch, Infinite Loop. Infinite Loop said: New Blog post: Testing Location Based iPhone Apps [...]

  2. S Briggs says:

    is there a more easier way to change the location? i mean like an app

    • Claus Broch says:

      I’m not sure I understand what you mean by changing the location by an App. You could always implement some way of manually entering a location in a test version of your App, but I’m not sure if that’s actually easier.

  3. I am currently developing a location based iPhone application. Is there any way to test the app other than taking the iPhone to different places?

  4. amit says:

    The user location can’t be updated for a MKMapView. So for navigation purposes, the FTLocationSimulator can’t simulate well.

    • Koko says:

      NOTE: They’ve renamed iPhone Simulator to iOS Simulator so this tmneiral command doesn’t work anymore. You can still go into the folder manually (the path is provided in that tmneiral command) and just right click and select Make Alias and put the alias/shortcut wherever you want (like in your Applications folder).

  5. Dipal Patel says:

    Any idea if we can do something similar on the BlackBerry?

  6. will says:

    do you know, does this tool work well in iOS 6 and Xcode 4.5

    • Claus Broch says:

      The iPhone simulator have had location simulation built in for some time, so the method described in this article is more or less obsolete. It is possible you might get it to work, but I have not verified this myself.

Leave a Reply