CLLocationManager on iPhone Simulator fails with kCLErrorDomain Code=0

29,251

Solution 1

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.

Solution 2

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.

Solution 3

Following Steps fixed my problem:

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

Solution 4

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

Solution 5

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.

Share:
29,251
albertamg
Author by

albertamg

Developer

Updated on July 09, 2022

Comments

  • albertamg
    albertamg almost 2 years

    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.

  • albertamg
    albertamg about 14 years
    My Wi-Fi (Airport) is enabled and I still have the same problem. Maybe the simulator can't locate my Wi-Fi, do I need to register the location of my Wi-Fi at Skyhook? (See stackoverflow.com/questions/2140340/…)
  • progrmr
    progrmr about 14 years
    I don't know, the simulator doesn't even use the WiFi, it always reports a fixed location in Cupertino anyway. Rather than spending a lot of time trying to fix it, you could just use this other solution: a CLLocation simulator for use on the simulator.
  • albertamg
    albertamg about 14 years
    OK, so... "You need Wi-Fi (Airport) enabled on your Mac for the simulator to report a position with Xcode 3.2.3" but... "the simulator doesn't even use the WiFi, it always reports a fixed location in Cupertino anyway. ". Wooow. Is it a bug or what? Thank you anyway, I'll try this other solution you mention.
  • progrmr
    progrmr about 14 years
    Let me know if that works for you too. It's kind of hard to believe but I turned it on off 3 times and got the same results each time.
  • Steven Dorfmeister
    Steven Dorfmeister almost 14 years
    This worked for me. I had the exact same problem over the last few days. Frustrating...I am on a iMac and turned on the AirPort...walla it location was updating properly again.
  • Tharindu Madushanka
    Tharindu Madushanka almost 14 years
    I am also having the same issue on my MacBook, I tried to turn On / Off Airport. Even restarted didn't seem to fix the issue. :( Has anybody found a solution ?
  • progrmr
    progrmr almost 14 years
    I ended up writing my own CLLocationManager simulator class so I could do more testing on the iPhone simulator. You can use that if you can't get the iPhone simulator to give you any location.
  • Ameya
    Ameya over 13 years
    I think it could be the problem with 4.x CL framework, which has its default location(infinite loop, CA) replaced by error code.
  • albertamg
    albertamg over 13 years
    Thanks for your reply but when I get the error my Airport is ON and I'm connected to a network (I've tried 3 different networks actually).
  • albertamg
    albertamg over 12 years
    +1 Thanks for the input. I explained my experience in an answer below.
  • progrmr
    progrmr over 12 years
    The simulator that comes with XCode 4.2 is much more capable. When running iOS Simulator, select the "Debug" menu, then select "Location" and you see a number of options for location simulation including Bike Ride, Freeway Drive, Custom Location, ...
  • albertamg
    albertamg over 12 years
    @progrmr Thanks for the tip :)
  • jerik
    jerik almost 11 years
    Good tip @Hemang, helped me out. I had this issue, after updateing my scheme. Before my Simulator had a location set, but somehow this vanished. I had to re-enter the "custom location" and it worked fine.
  • blueether
    blueether almost 10 years
    this did it for me. it was set to None in my project.
  • OneChillDude
    OneChillDude over 9 years
    Profoundly annoying gotcha :(. Thanks!
  • Giuseppe Galano
    Giuseppe Galano almost 9 years
    This worked for me! Now I have Scheme/Edit Scheme/Options/Allow Location Simulation checked, Default Location set to None in the Scheme Options, but Location set to Custom Location in the Debug menu/Location of the simulator.
  • 7stud
    7stud over 8 years
    Doesn't work for me. The error still appears occasionally.
  • kentr
    kentr about 8 years
    Was getting this error message in an Ionic / Cordova / PhoneGap app. Without knowing anything related to Scheme/Edit Scheme/Options/Allow Location Simulation, the fix for me was mostly the same: In the simulator itself, choose a location under Debug > Location.