Customize iOS Simulator preset locations to fake as current location

。_饼干妹妹 提交于 2019-12-06 10:26:13

问题


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?


回答1:


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

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


回答2:


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>

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.



来源:https://stackoverflow.com/questions/19694205/customize-ios-simulator-preset-locations-to-fake-as-current-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!