didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
Solution 1
-
Check that you actually have a valid WiFi and 3G connection
...if you do, then:
Go to settings and reset your location services
- 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:
- Press
command + shift + ,
in Xcode to open the scheme editor - Select the Run scheme
- Go to the Options tab
- Check ✅
Allow Location Simulation
- 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!
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...
.
Related videos on Youtube
Luca
Updated on September 22, 2020Comments
-
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, onlylocationManager:didFailWithError:
gets called, and prints this:didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
-
Andrew Smith over 10 yearsWow! 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 over 10 yearsAs 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 over 10 yearsOne upvote for pointing out reseting location services and network settings
-
Ray Lillywhite almost 10 yearsYou 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 over 9 yearsThat "bug" drove me crazy.
-
bendytree over 9 yearsWorked for me, but I also had to do
iOS Simulator
>Reset Content and Settings...
-
Vinzzz over 9 yearsI 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 almost 9 yearsThis has solved my issue...Thank you, 1. I have rewetted contents and settings.
-
Arpit B Parekh almost 9 years2. Removed data from derived data. 3. Restarted the Xcode, and Simulator and worked for me like a charm, thanks
-
Arpit B Parekh almost 9 yearsAme here I have also wasted 2 hours , set the Latitude and Longitude in correct positions.
-
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 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 about 8 years@MeM I never would have caught that. You just saved me HOURS.
-
cozmin-calin over 3 yearsWorked for me as well. Thanks