5

I'm looking since quite a long time something like a CLLocationManager simulator that would enable me to simulate GPS positions (CLLocation instances that could be retrieved through the CLLocationManager standard delegate mechanism) along a predefined route for instance (with a KML or GPX file as input, or whatever, but KML would be nice ;).

Something like this is available on the Android emulator and I was wondering if anything like this would exist for the iPhone simulator. At least this would be great and would speed up testing on the simulator instead of having to drive for real.... :/

If nothing like this exists, what would be your approach to fake such behavior and implement the simulator in such a way that the client is not impacted? (No code change in the delegate of the CLLocationManager for instance.)

Thanks for your links, hints, approaches...

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
yonel
  • 7,855
  • 2
  • 44
  • 51
  • I have just the same issue and so have spent time researching this issue. AFAIK, the iPhone simulator cannot be injected like android's. So, the currently suggested method is to read a file with lat/lon/alt/etc., and post those messages to the didReceiveLocationUpdate (IIRC) method. – KevinDTimm Jan 12 '10 at 10:37
  • Yes this was also my "desperate" solution :) But isn't there any open source project that would generate the didReceiveLocation at the appropriate rate for instance ? Or better, if you have recorded some gpx trace, would take into account the timestamps to reproduce the same scenario ? I've looked for such a thing but didn't manage to get one ? :O If I don't get any link for that I think I will start my own project around this.. :/ (or wait for SDK 4.0 ? ;) – yonel Jan 12 '10 at 10:52

2 Answers2

1

You can't inject the simulator, but you can subclass CoreLocation:

http://code.google.com/p/dlocation/

which subclasses CoreLocationDelegate to return real data on a device and data from a text file when on the simulator.

More info here

Testing CoreLocation on iPhone Simulator

HTH

Community
  • 1
  • 1
Andiih
  • 12,285
  • 10
  • 57
  • 88
  • I took a look at the approach in the project you refered to, but I think I found better than subclassing ;) My answer here : http://stackoverflow.com/questions/802156/testing-corelocation-on-iphone-simulator/2060315#2060315 – yonel Jan 13 '10 at 21:17
1

I think the best approach is to take control from the CLLocationManager by implementing your own category for it and simulate your expected behavior.

I put a description of this approach here : Testing CoreLocation on iPhone Simulator

Community
  • 1
  • 1
yonel
  • 7,855
  • 2
  • 44
  • 51