iphoneiosgpscore-location

Clear iPhone GPS coordinate cache to test poor GPS conditions?


Once an iOS device has acquired a GPS fix, it will cache that coordinate for quite some time, and return that coordinate immediately as soon as you send CLLocationManager a startUpdatingLocation message.

This makes it impossible to test the behavior of GPS-related code under a poor GPS condition in an even remotely reproducible fashion. Particularly, the scenario where a phone cannot acquire a fix and never calls locationManager:didUpdateToLocation:fromLocation: simply can't be tested.

Powering down the device does not clear the GPS cache.

How can I clear the GPS cache, and thus reproducibly test how my app behaves under a poor GPS scenario for real users in real situations?


Solution

  • The GPS cache can be found here: /var/root/Library/Caches/locationd You could use iPhone Explorer or DiskAid for Mac to reach and delete the folder.

    Regarding the larger problem of validating GPS data you might want to read Detecting Bad CoreLocation Data. He offers a helper method to validate location data. Good luck and hope this helps.