Not able to add "Privacy - Location Always and When in use usage description" in info.plist - Xcode 9 Beta

Viewed 19773

I am getting the following error while trying to ask permission from the user for location in Xcode 9 Beta. I tried adding "Privacy - Location When In Use Usage Description" and "Privacy - Location Usage Description" description in info.plist but still getting the same error.

This app has attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain both NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription keys with string values explaining to the user how the app uses this data

When i try to add "Privacy - Location Always and When in use usage description" it is automatically getting renamed to "Privacy - Location Usage Description" in info.plist

5 Answers

You need to add NSLocationAlwaysAndWhenInUseUsageDescription inInfo.plist this way

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>App_Name requires user’s location for better user experience.</string>

<key>NSLocationAlwaysUsageDescription</key>
<string>App_Name requires user’s location for better user experience.</string>

<key>NSLocationWhenInUseUsageDescription</key>
<string>App_Name requires user’s location for better user experience.</string>

Important note: It is

NSLocationAlwaysAndWhenInUseUsageDescription,

not

NSLocationAlwaysAndWhenInUsageDescription.

Apple made a typo in their Request Always Authorization guide (Last visited: September 20, 2017).

Just a heads up, it's not a typo as Hans suggested, it is correct. The format of the setting is confusing but conforms to something like

"[APIModule][Setting][KeyType]"

So the module the setting is for is the app's "NSLocation" calls, the setting is regarding the "Always and When in Use" setting for user location prefs, and the KeyType is a "Usage Description" therefore the resulting key is

NSLocationAlwaysAndWhenInUseUsageDescription

or separated into the composite terms:

NSLocation AlwaysAndWhenInUse UsageDescription

Related