CLLocationManager on iPhone Simulator fails with kCLErrorDomain Code=0

[亡魂溺海] 提交于 2019-11-28 21:03:34

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.

Zak

Following Steps fixed my problem:

  1. Under the Simulator menu: Reset Content and Settings....
  2. Close the simulator
  3. Restart your app.
Shefali Soni

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..

progrmr

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.

Hemang

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

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.

albertamg

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.

iNewbie

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.

artemisworks

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

bauerMusic

In Xcode 7 Simulator:

Hardware > Reboot

(Softer than "Reset Content and Settings")

David H

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

Undistraction

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

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

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