Simulating Core Location

iPhone developers using Core Location in their apps sometimes have a hard time. To test their apps, they have to go outside and conduct real-world tests. Not the worst thing fitness-wise, at least if you’re using a bike-mount holder, but rather inconvenient if you wanna attach your iPhone to your laptop running Xcode.

The iPhone simulator so far was not a big help because it only sends location updates from your Mac using Wi-Fi positioning. To test apps like Where To? which update POIs while moving, it’s not a practical solution.

That’s the reason we wrote our own Core Location simulator and presented it for the first time at the Macoun 2010 conference in Frankfurt. FTLocationSimulator delivers fake location updates to the application. The Core Location part is pretty straight-forward, we basically replicate the CLLocationManager API. The MapKit integration for the blue UserLocation dot is a bit harder: Apparently, Core Location talks directly to MapKit to update the position of the UserLocation dot. So we had to reach into our bag of tricks:

First, we determine the userLocation view and then we update their screen coordinates manually. As a side benefit, we nicely animate it as you can see in the video.

The waypoints for the location updates are taken from a KML file, in this case a route from Cupertino to San Francisco. You can use your own KML file by generating it with Google Earth (our KML “parser” is very basic and it’s not guaranteed to work with any KML file). If you watch the video closely, you’ll notice that the speed of the location updates varies. This is due to varying distances between waypoints on curvy or straight parts of the road. We currently don’t consider the distance between waypoints.

Integration of the code is easy and described in the Readme. At the moment, we don’t support advanced Core Location features such as speed, course, altitude, distance filtering and region monitoring. Also, our faked version of the UserLocation dot doesn’t have the nice halo GPS locating animation.

Nevertheless, we hope the code is useful for developers using Core Location in their apps. If you’re having feedback or wanna contribute to the project, we’re to glad to hear from you in the comments or on GitHub.

Update 04.02.2011: Deutsche Leser finden in der aktuellen Mac Developer 2/2011 unter dem Titel „Freie Fahrt am Schreibtisch“ einen Beitrag zu FTLocationSimulator und seiner Einbindung in iPhone-Apps.

2 Comments

  • livelybrowsers

    wrote on October 19, 2010 at 6:02pm

    Thanks for good stuff

  • seanlopez

    wrote on October 20, 2010 at 1:10pm

    Good article

Comments are closed.

Subscribe to the FutureTap Newsletter

View previous newsletters
Consent

We will use your name and email address to provide news and offers about our apps. We will treat your information with respect. By clicking below, you agree that we may process your information in accordance with our privacy policy.