Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize iOS Simulator preset locations to fake as current location

In the iOS simulator, one can select from some Apple pre-defined locations, or enter a custom latitude/longitude for your own location.

I want to customize that list of available locations. I see from this answer that one can provide a gpx file. However, I don't see where to do this in Xcode5 (the screenshots shown in the linked to answer are for Xcode 4).

Suggestions?

enter image description here

like image 934
idStar Avatar asked Mar 22 '23 20:03

idStar


2 Answers

I did this in Xcode 6 and here is how. Go to File>New>File choose 'Resource' under iOS and select GPX File. This will ask you to add the new file to you project like when you would add a class, add you file name. The file name you choose will be the name of your location. Mine is SaoPaulo.gpx file. Open the file from Navigator panel. All you have to do is add floating point values of lat, lon and your custom location name as shown below.

Run you code and you should see the tilted blue arrow in debugger area, now you can simulate to your custom locations. Obviously I have three custom files.

<?xml version="1.0"?>
<gpx version="1.1" creator="Xcode"> 
    <wpt lat="-22.907104" lon="-47.063240">
         <name>SaoPaulo</name>
    </wpt>
</gpx>

enter image description here

If you notice at the bottom of the dropdown list there is an option 'Add GPX File to Workspace..' I tried using this by creating my own GPX file from TextEdit and add the file to my project but somehow my file's contents got messed up due to the extra Ascii characters from the Text app. So the above method is a lot easier.

like image 98
Ohmy Avatar answered Apr 25 '23 20:04

Ohmy


EDIT: Another way to achieve this to edit your run scheme and select options. and provide GPX file in default location dropbox.Make sure that allow location simulation is enabled.

https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/iOS_Simulator_Guide/CustomizingYourExperienceThroughXcodeSchemes/CustomizingYourExperienceThroughXcodeSchemes.html#//apple_ref/doc/uid/TP40012848-CH6-SW1

enter image description hereIt's at the bottom, in the debugger, an icon that looks like the GPS active icon (from iOS status bar).

like image 27
ManicMonkOnMac Avatar answered Apr 25 '23 21:04

ManicMonkOnMac