Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode / iOS simulator: Trigger significant location change manually

Is there a way to manually tell the device to dispatch a significant location change notification that will wake up any applications registered for this notification? This is for testing only, and I realize this private API call would get rejected upon submission to the app store.

like image 762
Nick Avatar asked May 27 '11 22:05

Nick


People also ask

How do I change the default location in iOS simulator?

in iOS Simulator menu, go to Debug -> Location -> Custom Location. There you can set the latitude and longitude and test the app accordingly.

How do I change the time zone in iOS simulator?

When changing the timezone, I found the easiest way to do it was by clicking the clock in the menubar. And then selecting "Open Date & Time Preferences" then select the tab Time Zone. Alternatively System Preferences -> Date and Time and select the tab Time Zone.

How do you simulate a location?

In some Android versions, you have to put a check in the box next to the Allow mock locations option on the Developer options screen. Use the back button to return to the app, and search for the location you want to fake on your phone. If you're making a route, tap-and-hold on the map to drop place markers.


1 Answers

So two answers:

A) Hop on a train :-)

B) Use the simulator. In iOS 5.x simulator, there is a debug menu that has a location submenu. Choose freeway drive. This will start the simulator on an imaginary journey down the scenic 280 in Northern California. It gives you everything but the view: your app will get Significant Location Change updates, and will also be launched in the background if it has been suspended.

To verify that you are actually moving, launch safari in the simulator, and go to maps.google.com and click the little track my location button. You should be moving.

Awesome! Now how to debug the lifecycle problem of being launched by the system? Easy! Have xCode wait for your app to be launched to start debugging. From the Scheme menu, choose edit scheme. In the Run Scheme, and the Info tab, for the "Launch" setting choose : "Wait for My.app to launch".

Run your app once in the simulator, so that it starts monitoring for location updates, then force quit it, so that it is suspended. Add a break point in your application did finish launching function, and wait. As soon as your simulator has gone far enough, your application will be woken up, your breakpoint hit, and you are in the money.

But really, the train ride is more fun.

like image 180
MagicSeth Avatar answered Oct 04 '22 23:10

MagicSeth