Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulating location changes for `startMonitoringSignificantLocationChanges`

I am writing an iPhone app and using Location Services. I am using the startMonitoringSignificantLocationChanges method on CLLocationManager. (As I understand, this is for low power, low accuracy location services.) When I build and launch my app in iOS Simulator, it gets my location fine. However, I want to simulate updates to the location beyond the initial fix.

I did notice these two options:

  • iOS Simulator : Debug > Location menu
  • Xcode 4: Product > Debug > Simulate Location menu

Both of these work acceptably for simulating an initial fix. (For example, choose 'Apple' from the former, or 'Moscow' from the latter.) However, subsequent changes to either of these will NOT trigger another location update in the simulated app.

What I desire is to be notified when the simulated location changes when using startMonitoringSignificantLocationChanges. (iOS Simulator does generate a series of updates when I use startUpdatingLocation instead.) This makes it way easier to test location-enabled applications without taking the device out into the field.

Two questions:

  • What is the difference between these two?
  • How do I use iOS Simulator and/or Xcode 4 to simulate a series of location changes?

Cheers.

like image 945
ocarlsen Avatar asked Dec 17 '11 01:12

ocarlsen


People also ask

How do you simulate a location in Simulation?

Click the location on the map you want to simulate, and then press the lowercase L key. A dialog will appear with the message, “Simulated Location Set”. After a short time, the simulated location you set in the Editor will appear as a pink dot in the Android Emulator. Click anywhere on the map, and press Shift+L.

How do I change my current location in Simulation?

Change location when the application is running Verify that location simulation is allowed for your run/debug configuration. Start running ⇧ F10 or debugging ⇧ F9 the application. Select a desired location from the list that opens. This location will be simulated on your device, but won't be saved in the list.

How do you change simulate location on iPhone?

To simulate location on a Simulator, select Features menu > Location, then you will see a list of location and movement options you can simulate. A list of location and movement options you can simulate in a Simulator.


1 Answers

If you want to make a track, you can create a GPX file with waypoints like this:

<?xml version="1.0" encoding="UTF-8"?> <gpx>     <wpt lat="52.373" lon="4.871"></wpt>     <wpt lat="52.374" lon="4.872"></wpt>     <wpt lat="52.375" lon="4.871"></wpt> </gpx> 

Save it as track.gpx. Be careful of having no whitespace at the start.

When you Build and Run, there's a toolbar at the bottom of Xcode with a location arrow (similar to the one on iPhones). It's for "Simulate Location". Click there and load in your GPX file. When your app is running in the Simulator, the blue dot should move around. I don't think there's a way to control the timing, so it updates its location every half second or so.

The difference I can see in the Simulator menu is that you can't have a custom track, only a custom point. I don't know why the menus options are different, they'll probably add an option for a custom track in the Simulator at some point.

like image 165
nevan king Avatar answered Oct 07 '22 19:10

nevan king