在 iOS 模拟器中,您可以从一些 Apple 预定义的位置中进行选择,或者为您自己的位置输入自定义纬度/经度。
我想自定义可用位置的列表。我从这个答案中看到可以提供一个 gpx 文件。但是,我看不到在 Xcode5 中的何处执行此操作(链接到答案中显示的屏幕截图适用于 Xcode 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>
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.
编辑:实现此目的的另一种方法是编辑运行方案并选择选项。并在默认位置 dropbox 中提供 GPX 文件。确保启用了允许位置模拟。
它位于调试器的底部,一个看起来像 GPS 活动图标的图标(来自 iOS 状态栏)。