通过 Xcode 意外覆盖了 iPhone 设备位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26261248/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:48:55  来源:igfitidea点击:

Accidentally overwrote iPhone device location via Xcode

iosiphonexcode

提问by Jon Gold

So I'm working on a location-based iPhone app. I'm mainly testing on the iOS simulator, and as such using the Core Location Simulation. All good - I can pretend to be in New York or San Francisco or wherever.

所以我正在开发基于位置的 iPhone 应用程序。我主要在 iOS 模拟器上进行测试,因此使用 Core Location Simulation。一切都很好 - 我可以假装在纽约或旧金山或任何地方。

Then I move to testing my app on my iPhone, with that checkbox still enabled. I go for a walk (in, like, the actual real world), pull out Google Maps, and realise that my actual, not-simulator iPhone is using a simulated location. In this instance my iPhone is stuck thinking that it's in London (where I live), but right central in Picadilly Circus, not where I am.

然后我开始在我的 iPhone 上测试我的应用程序,该复选框仍然启用。我出去散散步(在真实世界中),打开 Google 地图,然后意识到我的实际非模拟器 iPhone 正在使用模拟位置。在这种情况下,我的 iPhone 一直以为它在伦敦(我住的地方),但在皮卡迪利广场的正中央,而不是我所在的地方。

I get home, open up Xcode, and to make sure I've nailed down the cause (rather than just a weird GPS bug etc), change the 'default location' to Johannesburg. Unplug my phone, open Google Maps (and Foursquare, to be sure), same deal. Stuck in Johannesburg.

我回到家,打开 Xcode,并确保我已经确定原因(而不仅仅是一个奇怪的 GPS 错误等),将“默认位置”更改为约翰内斯堡。拔掉我的手机,打开谷歌地图(当然还有 Foursquare),同样的交易。被困在约翰内斯堡。

So it's definitely this panel here that's borked my phone, but I can't figure out how to reset it.

所以肯定是这里的这个面板让我的手机崩溃了,但我不知道如何重置它。

Things I've tried that don't seem to work:

我尝试过但似乎不起作用的事情:

  • changing 'default location' to 'none' & rerunning
  • disabling 'allow location simulation' & rerunning
  • 将“默认位置”更改为“无”并重新运行
  • 禁用“允许位置模拟”并重新运行

So it seems once you've given your iPhone an arbitrary location to pretend to be in, just disabling that doesn't fix it.

因此,似乎一旦你给你的 iPhone 一个任意的位置来假装在里面,只是禁用它并不能解决它。

Location Simulation

位置模拟

Any ideas? I'm going travelling in a few days and really need my GPS to work!

有任何想法吗?我几天后要去旅行,真的需要我的 GPS 来工作!

采纳答案by Tim Camber

This has happened to me before, it was very strange and mysterious!

我以前也遇到过这种情况,很奇怪很神秘!

I don't remember how I fixed it, but: have you tried Reset Location & Privacyin the Settings app? If all else fails, I suspect Reset All Settingswould maybe work.

我不记得我是如何修复它的,但是:您是否Reset Location & Privacy在“设置”应用中尝试过?如果一切都失败了,我怀疑Reset All Settings可能会奏效。

As I try to remember, I think maybe hard rebooting the phone might also work (just turn it off, turn it back on).

正如我试图记住的那样,我认为硬重启手机也可能有效(只需将其关闭,然后重新打开)。

回答by Anthony Mattox

While you have your device connected to the debugger there is a little button at the top of the debug panel. Right here:

当您将设备连接到调试器时,调试面板顶部有一个小按钮。就在这儿:

enter image description here

在此处输入图片说明

Click on that and you can select 'don't simulate location', exit the app, and I think you'll be good to go.

点击它,你可以选择“不模拟位置”,退出应用程序,我想你会很高兴。

I'm a little foggy too on how that relates to the location defined in the scheme and the location set in the simulator. I usually find it easier to set a location in the simulator itself rather than in the scheme (at least when testing in the simulator is possible) to avoid issues like this. In the simulator if you enter a location under 'Debug > Location > Custom Location...' while the simulator is on the springboard the location will persist between launches of the app and the simulator.

我也有点不明白这与方案中定义的位置和模拟器中设置的位置有何关系。我通常发现在模拟器本身而不是在方案中设置位置更容易(至少在可以在模拟器中进行测试时)以避免此类问题。在模拟器中,如果您在“调试 > 位置 > 自定义位置...”下输入一个位置,而模拟器位于跳板上,则该位置将在应用程序和模拟器启动之间保持不变。

回答by rahul_send89

just Reset Location & Privacy. turnoff location service. restart your phone .. turn on location service. try using google maps .. it work for me ..

只是Reset Location & Privacy。关闭location service。重启你的手机..打开location service。尝试使用谷歌地图..它对我有用..

回答by Reeder32

The important step is the hard reset after resetting location settings. Not sure if you need to do anything in Xcode, but it is a good idea to select 'Don't simulate location'

重要的一步是重置位置设置后的硬重置。不确定您是否需要在 Xcode 中执行任何操作,但最好选择“不模拟位置”

回答by Isaac Dougherty

Go back to Xcode (or whatever coding software you are using) and rerun the application, then select don't simulate location.

返回 Xcode(或您使用的任何编码软件)并重新运行应用程序,然后选择不模拟位置。

回答by Ranjith

Goto Settings>Privacy>Location Services. Turn-Off Location Services. Restart the phone. Open Google maps. A popup will come to enable location service, click on the options given that will take you directly to Settings. If popup didn't appear in Google Maps, click on Mylocation button at the bottom. Enable Location services and get back to Google Maps. It re-enabled the real Location for me.

转到设置>隐私>定位服务。关闭定位服务。重启手机。打开谷歌地图。将出现一个弹出窗口以启用定位服务,单击给出的选项,将直接带您进入设置。如果弹出窗口没有出现在谷歌地图中,​​点击底部的我的位置按钮。启用定位服务并返回 Google 地图。它为我重新启用了真正的位置。