How to set the location in the iOS simulator without writing code?

半城伤御伤魂 提交于 2019-12-10 03:59:55

问题


My problem was how to set the gps location of my app when running in the iOS simulator

The home screen in my app displays sunrise and sunset times based on gps location and I wanted a screen shot with sensible values - I'm in the UK and the sunrise times were showing UK times for American sunrise and sunset.

As it is on the launch screen one solution, going to Debug -> Simulate Location, is too late for me.

Took me a while to work out and I wasn't finding the answer when I searched here (maybe not asking the question the right way . So I'm going to answer my own question below in the hope it stops someone else wasting their time


回答1:


add a .GPX file to your project, and use XCode's location simulation feature. You can set up the location simulation as part of your scheme, so it's in place at launch time. Look under Edit Scheme, select "Run" at left, go to Options tab.




回答2:


You can Simulate Location Position with Xcode:

From here, if you stops the build sometimes is returning to Don't Simulate Location.

However, clicking Run, while the app is running, Xcode asks you to Stop and Run, click Stop and the Simulator runs again the build. This time, for sure, with your Location.




回答3:


My solution turned out to be easy

Click on the name of the project (next to the run and stop buttons in the top left of the Xcode screen) and select Edit Scheme.

Go to the options pane.

The first thing is Core Location allow Location simulation. Then below that set Default Location to the one you want.

Done




回答4:


The EASIEST way is to go to the debug tab of the simultor :

then go to the location button, and you can set the location you want :



来源:https://stackoverflow.com/questions/22715142/how-to-set-the-location-in-the-ios-simulator-without-writing-code

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