Fixed Error Domain=kCLErrorDomain Code=1 “(null)”

Tim Chang
Jul 25, 2023

--

When you were trying to use Location Service to get user’s current location. Even it already popped up a dialog to grant Location permission, you could not get the location and saw error message by

locationManager(_:didFailWithError:) Error Domain=kCLErrorDomain Code=1 "(null)"

The way to fix it is very simple. Just launch System Setting, go to Privacy and Security and Location Services. Then, switch on for your app. It is done. You don’t need to relaunch your app, it will be updated again by itself.

Switch on Location Service for your app

Additional

If you are working on testing your app on iOS/iPad Simulator, you can choose one of built-in location for the simulation or input your lat/lon manually.

Change your location in Simulator
Input your Lat and Lon for yourself

--

--

Tim Chang

A software engineer at Microsoft. I love to enjoy programming, playing games, listening to music, taking photos and making great latte.