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

87,424

Solution 1

  1. Check that you actually have a valid WiFi and 3G connection

    ...if you do, then:

  2. Go to settings and reset your location services

  3. Reset your network settings

This should take care of that issue. It is device/network related not app related. It's annoying especially if your app is dependent on location services and the device is WiFi only and people give negative ratings on the AppStore... Pardon me, I'm getting a bit emotional there.

Solution 2

If you are using the simulator:

  1. Press command + shift + , in Xcode to open the scheme editor
  2. Select the Run scheme
  3. Go to the Options tab
  4. Check ✅ Allow Location Simulation
  5. Select a Default Location in the dropdown

Selecting None as your Default Location may have caused the problem.

Solution 3

Simply ignore this error and wait for more updates or a different error.

The docs for the location manager say that this error is temporary. It's letting you know that it failed to immediately retrieve a location, but it continues to try. "In such a situation, you can simply ignore the error and wait for a new event." Which is a really boneheaded way to use a method named locationManager:didFailWithError: - Thanks Apple!

Apple Documentation

Solution 4

Try restarting the simulator (assuming that's what you're using).

After trying everything else this worked for me.

Solution 5

A restart of the simulator didn't work for me.

I had to clear everything via "iOS Simulator" >> "Reset Content and Settings....

Share:
87,424

Related videos on Youtube

Luca
Author by

Luca

Updated on September 22, 2020

Comments

  • Luca
    Luca almost 4 years

    I want to get the current location, but instead I get an error.

    This is a snippet of my view controller.

    - (void)viewDidLoad {
        self.locationManager = [[CLLocationManager alloc] init];
        [locationManager setDelegate:self];
        [locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
        [locationManager startUpdatingLocation];
    }
    
    - (void)locationManager:(CLLocationManager *)manager 
         didUpdateLocations:(NSArray<CLLocation *> *)locations {
        // I would get the latest location here
        // but this method never gets called
    }
    - (void)locationManager:(CLLocationManager *)manager 
           didFailWithError:(NSError *)error {
        NSLog(@"didFailWithError: %@", error);
    }
    

    I'm expecting the delegate method locationManager:didUpdateLocations: to get called, but instead, only locationManager:didFailWithError: gets called, and prints this:

    didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)" 
    
  • Andrew Smith
    Andrew Smith over 10 years
    Wow! Thanks, I've been chasing this for weeks. My app kept forcing my iPad or iPhone to the London, England location, and I could not figure out why. I turned that option off and the problem is gone.Maybe it was having a hiccup grabbing the location and then going off and changing the location to the one on the Scheme.
  • Durai Amuthan.H
    Durai Amuthan.H over 10 years
    As far as I know GPS doesn't need either internet or wifi connection.It's just a receiver if it is in accessible location with 2 or 3 of GPS satellites we can get the geo location coordinates.Then why does the error come if there is no internet or wifi connection?
  • Durai Amuthan.H
    Durai Amuthan.H over 10 years
    One upvote for pointing out reseting location services and network settings
  • Ray Lillywhite
    Ray Lillywhite almost 10 years
    You shouldn't have to go through these steps. Simply ignore this error and wait for more updates. See my answer below or view the docs at developer.apple.com/library/ios/documentation/corelocation/…‌​:
  • Hermann Klecker
    Hermann Klecker over 9 years
    That "bug" drove me crazy.
  • bendytree
    bendytree over 9 years
    Worked for me, but I also had to do iOS Simulator > Reset Content and Settings...
  • Vinzzz
    Vinzzz over 9 years
    I had exactly the same problem, while playing with MapKit & CoreLocation, on my device (iPhone 5S, iOS 8.1.3). I was unable to get a location, and got the same error again & again (in spite of a good mobile network signal). Until I switched the WiFi On, and everything was fixed! Weird... Thanks !
  • Arpit B Parekh
    Arpit B Parekh almost 9 years
    This has solved my issue...Thank you, 1. I have rewetted contents and settings.
  • Arpit B Parekh
    Arpit B Parekh almost 9 years
    2. Removed data from derived data. 3. Restarted the Xcode, and Simulator and worked for me like a charm, thanks
  • Arpit B Parekh
    Arpit B Parekh almost 9 years
    Ame here I have also wasted 2 hours , set the Latitude and Longitude in correct positions.
  • whoKnows
    whoKnows over 8 years
    @DuraiAmuthan.H iPads don't have actual GPS hardware. They use a database of wifi MAC addresses to determine your location.
  • Durai Amuthan.H
    Durai Amuthan.H over 8 years
    @whoKnows - They have GPS receiver builtin.. assisted GPS.. It uses Wifi signal and or Cellular towers to triagulate position..3G/LTE iPad has a real GPS built-in
  • Sam Ballantyne
    Sam Ballantyne about 8 years
    @MeM I never would have caught that. You just saved me HOURS.
  • cozmin-calin
    cozmin-calin over 3 years
    Worked for me as well. Thanks