[Xcode] iPhone device couldn’t prompt Location Request

Tim Chang
Jul 28, 2023

--

As title, you used LocationManager to request the permission and user’s current location in your code, but the devices couldn’t pop up a dialog to ask Location Service usage. It is because you forget to add Privacy information in Info.plist.

override init() {
super.init()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}

It is very simple to fix but hard to figure out where the location it is.

Info.plist is located in Project’s Build Settings

You just add “Yes” for “Privacy — Location When In Use Usage Description”, or the other one for “Always Usage”. Then rebuild and redeploy the app to your device. It will pop up the dialog to ask Location Service permission. Hope this could help you resolve this issue. :)

--

--

Tim Chang

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