Customize iOS Simulator preset locations to fake as current location
Asked Answered
W

2

4

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

Waler answered 30/10, 2013 at 21:32 Comment(1)
possible duplicate of Set the location in iPhone SimulatorHairless
M
3

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).

Micrography answered 30/10, 2013 at 21:48 Comment(4)
Thanks for the screen shot. I'm versed with the major panes in Xcode, but here's the thing: even with the Mapping framework added in the project (mapping is working), the debugger pane does not have that location icon. The icon in your screenshot is similar to what was linked in the Xcode4 answer. There's some reason I'm not getting this location icon in the debugger controls pane.Waler
can you post a screenshot?Micrography
in you scheme in options is allow location enabled?Micrography
This finally worked. By going into my Scheme options, although 'Allow Location Simulation' was always checked, just going in to that view meant that when I ran the app the next time, the little location icon in the debug pane I was originally expected, finally showed up. I'll chock it up to an Xcode5 bug (as to why it didn't show in the first place). Thanks!Waler
R
4

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.

Radiotelegraphy answered 4/12, 2014 at 17:8 Comment(0)
M
3

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).

Micrography answered 30/10, 2013 at 21:48 Comment(4)
Thanks for the screen shot. I'm versed with the major panes in Xcode, but here's the thing: even with the Mapping framework added in the project (mapping is working), the debugger pane does not have that location icon. The icon in your screenshot is similar to what was linked in the Xcode4 answer. There's some reason I'm not getting this location icon in the debugger controls pane.Waler
can you post a screenshot?Micrography
in you scheme in options is allow location enabled?Micrography
This finally worked. By going into my Scheme options, although 'Allow Location Simulation' was always checked, just going in to that view meant that when I ran the app the next time, the little location icon in the debug pane I was originally expected, finally showed up. I'll chock it up to an Xcode5 bug (as to why it didn't show in the first place). Thanks!Waler

© 2022 - 2024 — McMap. All rights reserved.