After upgrading my development tools to XCode 4.2 and iOS 5, I started to run into location unavailable errors when running in the iOS Simulator.
Having battled with the Android Emulator over the years, I figured there was a new location services setting I missed.
After a quick look at the iOS Simulator’s debug menu I found what I was looking for. Apple has changed the Location options for the better. You now have full control over their settings, similar to the Android emulator, just much easier.
By default the simulator will have no location defined. Depending on your development platform this can surface in a variety of errors. Below is the error Appcelerator’s Titanium provides.
To define your location, simply open the iOS Simulator and select the Debug option, then select Location. This has seven options:
-
None – This will not return any location information. You can use this to test when the GPS is unavailable.
-
Custom Location – This allows you to set a specific Latitude and Longitude.
-
Apple Stores – Uses an Apple Store’s coordinates
-
Apple – Apple headquarters coordinates
-
City Bicycle Ride – Simulation of a bicycle ride in Cupertino, ie the device simulate it is moving
-
City Run – Simulation of a run in Cupertino, ie the device simulate it is moving
-
Freeway Drive – Simulation of a drive in Cupertino, ie the device simulate it is moving
I have a series of geo location test cases, so I tend to use the Custom Location option since it allows me to enter specific coordinates.
This will open a dialog that allows you to enter your Latitude and Longitude.
Press Ok, and you are ready to go. The iOS Simulator will remember your Custom Location between restarts of the simulator. You will need to remember to update your Latitude and Longitude when testing different scenarios or traveling. But Apple has made the process extremely straight forward.
The new location options in the iOS 5 simulator are a big improvement for anyone doing location based applications.