iPhone 模拟器上的 CLLocationManager 失败,kCLErrorDomain Code=0

发布于 2024-09-06 17:33:03 字数 679 浏览 8 评论 0原文

iPhone Simulator 上的 CLLocationManager 应该会伪造 Cupertino(不是吗?),但事实并非如此,它会失败并显示 kCLErrorDomain Code=0 。 LocationManager 的委托收到消息 didFailWithError。实现此方法是为了记录错误,控制台输出以下内容:

Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"

当我遇到此问题时,我正在处理一个真实的项目,但讨论我的代码是毫无意义的,因为我下载了“位置”示例代码(更新于 2010 年 06 月) 22 for iOS 4) 来自开发中心,问题仍然存在。

该应用程序应该在收到第一个位置更新时启用“添加”按钮,以便用户可以跟踪他们的位置,但它什么也不做。

我在 didFailWithError 的实现中添加了一行(简单的)来记录错误(如果有)。我收到上述错误。

使用 Xcode 3.2.2 和目标 3.1.3,我可以在运行旧版本的“Locations”项目时获得固定位置(Cupertino)。

有人可以帮忙吗?

谢谢。

CLLocationManager on iPhone Simulator is supposed to fake Cupertino (isn't it?) but it does NOT, it fails with kCLErrorDomain Code=0 instead. LocationManager's delegate receives the message didFailWithError. This method is implemented to log the error and the console outputs the following:

Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"

I was working on a real project when I ran into this problem but it is pointless to discuss my code because I downloaded "Locations" sample code (updated 2010-06-22 for iOS 4) from the dev center and the problem persisted.

The app is suposed to enable an "add" button when it receives the first location update so users can track their locations but it does nothing.

I added one (trivial) line to the implementation of didFailWithError to log the errors, if any. I get the error described above.

With Xcode 3.2.2 and targeting 3.1.3, I could get a fixed location (Cupertino) when running an older version of the "Locations" project.

Can somebody help?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

白日梦 2024-09-13 17:33:03

如果您选中了方案/编辑方案/选项/允许位置模拟但没有设置默认位置,也会出现此错误。

请检查这一点,它可能会解决您的问题。

This error also occurs if you have Scheme/Edit Scheme/Options/Allow Location Simulation checked but don't have a default location set.

Please check this it may resolve your issue.

马蹄踏│碎落叶 2024-09-13 17:33:03

以下步骤解决了我的问题:

  1. 在模拟器菜单下:重置内容和设置...
  2. 关闭模拟器
  3. 重新启动您的应用。

Following Steps fixed my problem:

  1. Under the Simulator menu: Reset Content and Settings....
  2. Close the simulator
  3. Restart your app.
青春有你 2024-09-13 17:33:03

我遇到了同样的情况并按照以下步骤操作,可能会有所帮助:)

1) 转到模拟器(无论哪个版本)

2) 进入调试菜单 ->位置->选择 Apple 作为您的定制
位置。

它开始在我的情况下起作用..

I faced same situation and have followed this steps, may be it helps:)

1) Go to Simulator (whichever version)

2) Go to Debug menu -> Location -> Select Apple as your custom
location.

it started working in my case..

谷夏 2024-09-13 17:33:03

我之前听说过这个报道但直到现在我自己才看到它。因为我使用以太网,所以我在 MacBook 上关闭了 Airport。我打开机场并重新启动模拟器,现在它可以工作了。

您需要在 Mac 上启用 Wi-Fi(机场),模拟器才能使用 Xcode 3.2.3 报告位置。

I've heard this reported before but never saw it myself until just now. I had Airport turned off on my MacBook since I was using ethernet. I turned on Airport and restarted the simulator and now it works.

You need Wi-Fi (Airport) enabled on your Mac for the simulator to report a position with Xcode 3.2.3.

铁憨憨 2024-09-13 17:33:03

如果您选中了方案/编辑方案/选项/允许位置模拟但未设置默认位置,也会出现此错误。

This error also occurs if you have Scheme/Edit Scheme/Options/Allow Location Simulation checked but don't have a default location set.

不乱于心 2024-09-13 17:33:03

它对我做了同样的事情:

它首先显示位置,然后我安装了 XCode 4.2 beta,然后当我回到 4.1 时,位置不再显示,并且 CLLocationManager 抛出位置错误。

我执行了以下操作,问题得到了解决(我不知道是否需要执行这两项操作,或者只执行一项操作就足够了,因为现在它可以工作但无法重现):

然后运行模拟器:

  • 拔掉网线
  • 将模拟器中的设备更改为 iPhone(视网膜):硬件 >设备> iPhone(视网膜)

我错误地执行了此操作,它修复了我的 iMac 上的位置。

It did the same to me:

It showed the location at first, then I installed the XCode 4.2 beta, then when I went back to 4.1 location was not showing anymore and CLLocationManager was throwing a location error.

I did the following, and the problem was fix (I don't know if both actions are required or only one will suffice, because now it works and can't reproduce):

Run the simulator then:

  • unplug the network cable
  • change the device in simulator to iPhone (retina): Hardware > Device > iPhone (Retina)

I did this by mistake, and it fixed the location on my iMac.

深者入戏 2024-09-13 17:33:03

CLLocationManager 再次开始在 iOS Simulator 5.0 上按预期工作。

根据我的经验,它曾经在 iOS Simulator 4.04.3 上始终失败,并显示 kCLErrorDomain Code=0。按照其他答案的建议,打开机场并连接到 Wi-Fi,对我的情况没有帮助。不过,我还是要感谢大家的回答。我只是通过测试设备上的所有核心位置代码来解决这个问题。

最近,我升级到了 XCode 4.2(从 XCode 3.2.6)以及随之而来的 iOS Simulator 5.0,结果,我注意到 CLLocationManager 再次开始按预期工作。当在 XCode 4.2 中选择较旧的模拟器时,它总是失败;这表明模拟器是罪魁祸首。

CLLocationManager started to work as expected again on the iOS Simulator 5.0.

In my experience, it used to fail consistently with kCLErrorDomain Code=0 on the iOS Simulator 4.0 through 4.3. Turning the airport on and connecting to a Wi-Fi, as suggested by the other answers, did not help in my case. However, I would like to thank everybody for their answers. I simply worked around this issue by testing all the Core Location code on a device.

Recently I upgraded to XCode 4.2 (from XCode 3.2.6) and the iOS Simulator 5.0 that comes with it, and as a result of that, I noticed that the CLLocationManager started to work as expected again. When selecting an older simulator in XCode 4.2, it keeps failing; which points to the simulator as the one to blame.

滥情稳全场 2024-09-13 17:33:03

机场需要打开并关闭您必须加入网络。至少那是我的经历。当我刚打开它时,我不断收到同样的错误。加入我的无线网络,错误就消失了。

Airport needs to be turned ON & you must join a network. At least that was my experience. When I just turned it on, I kept getting the same error. Joined my wireless network and the error went away.

可是我不能没有你 2024-09-13 17:33:03

我一直收到错误消息,直到我打开 Airport 并连接到 wifi 网络(不确定我是否应该使用该网络!)...并且 CLLocationManager 在持续失败多年后仍然可以工作。这是一个巨大的模拟器错误还是什么??

苹果 - 请修复它! :P

I kept getting an error until I switched my Airport on and connected to a wifi network (not sure if I am even supposed to be on that one!)... and CLLocationManager worked after failing consistently for ages. Is this a huge Simulator bug or what??!

Apple - PLEASE fix it! :P

作妖 2024-09-13 17:33:03

在 Xcode 7 模拟器中:

硬件>重新启动

(比“重置内容和设置”更柔和)

In Xcode 7 Simulator:

Hardware > Reboot

(Softer than "Reset Content and Settings")

初相遇 2024-09-13 17:33:03

我通常连接以太网进行模拟器测试 - 我遇到了这个失败。打开 WIFI,但不使用它来传输数据(未连接到任何东西)——现在一切正常。

所以,解决方案是 - 只需打开 WIFI(我也退出并重新启动模拟器,不确定是否需要)。

Lion 和 Xcode 4.2

I'm normally Ethernet connected doing Simulator testing - I got this failure. Turned on WIFI, but not using it for data (didn't connect to anything) - now everything works.

So, the solution was - just turn on WIFI (I also quit and restarted the Simulator, not sure if needed to).

Lion and Xcode 4.2

同展鸳鸯锦 2024-09-13 17:33:03

在 iOS 5.0.1 中,在以下条件下仍然会出现这种情况:

  1. 在没有 Wi-Fi 连接的情况下运行模拟器
  2. 连接到 Wi-Fi 网络
  3. [结果] CLLocationManager 失败,并出现此问题中概述的错误。
  4. [修复]重启模拟器

This still occurs in iOS 5.0.1 under the following conditions:

  1. Run simulator in a situation without a wi-fi connection
  2. Connect to a wi-fi network
  3. [Result] CLLocationManager fails with error in outlined in this question.
  4. [Fix] Restart Simulator
计㈡愣 2024-09-13 17:33:03

首先转到 Xcode 日志栏并设置“不模拟位置”。
然后选择模拟器菜单>调试>位置>设置自定义或选择任何一个。

First Go to Xcode log bar and set "Dont simulate location".
Then select simulator menu>debug>location>set custom or select any.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文