无法在 info.plist - Xcode 9 Beta 中添加“隐私 - 位置始终和使用时使用说明”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45033600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Not able to add "Privacy - Location Always and When in use usage description" in info.plist - Xcode 9 Beta
提问by yaali
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.
我在 Xcode 9 Beta 中尝试向用户请求位置许可时收到以下错误。我尝试在 info.plist 中添加“Privacy - Location When In Use Usage Description”和“Privacy - Location Usage Description”描述,但仍然出现相同的错误。
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
此应用程序试图在没有使用说明的情况下访问隐私敏感数据。应用程序的 Info.plist 必须同时包含 NSLocationAlwaysAndWhenInUseUsageDescription 和 NSLocationWhenInUseUsageDescription 键和字符串值向用户解释应用程序如何使用这些数据
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
当我尝试添加“隐私 - 位置始终和使用时使用说明”时,它会在 info.plist 中自动重命名为“隐私 - 位置使用说明”
采纳答案by mawus
Add "NSLocationAlwaysAndWhenInUseUsageDescription" instead of "Privacy - Location Always and When in use usage description". In the current beta it won't get renamed to anything but it shows the correct dialog for iOS 11.
添加“ NSLocationAlwaysAndWhenInUseUsageDescription”而不是“ Privacy - Location Always and When in use using description”。在当前的测试版中,它不会重命名为任何内容,但会显示适用于 iOS 11 的正确对话框。
回答by Gonzalo Dura?ona
Basically it says you are required to include the NSLocationWhenInUseUsageDescription and NSLocationAlwaysAndWhenInUsageDescription keys in your app's Info.plist file. (If your app supports iOS 10 and earlier, the NSLocationAlwaysUsageDescription key is also required.) If those keys are not present, authorization requests fail immediately.
基本上它说你需要在你的应用程序的 Info.plist 文件中包含 NSLocationWhenInUseUsageDescription 和 NSLocationAlwaysAndWhenInUsageDescription 键。(如果您的应用支持 iOS 10 及更早版本,则还需要 NSLocationAlwaysUsageDescription 密钥。)如果这些密钥不存在,授权请求将立即失败。
I'm currently using Xcode Version 9.0 beta 5 (9M202q) and it works without issues.
我目前使用的是 Xcode 版本 9.0 beta 5 (9M202q),它可以正常工作。
回答by Hans Kn?chel
Important note: It is
重要提示:它是
NSLocationAlwaysAndWhenInUseUsageDescription
,
NSLocationAlwaysAndWhenInUseUsageDescription
,
not
不是
NSLocationAlwaysAndWhenInUsageDescription
.
NSLocationAlwaysAndWhenInUsageDescription
.
Apple made a typo in their Request Always Authorizationguide (Last visited: September 20, 2017).
Apple 在他们的Request Always Authorization指南(上次访问时间:2017 年 9 月 20 日)中打错了字。
回答by swiftBoy
You need to add NSLocationAlwaysAndWhenInUseUsageDescriptioninInfo.plist this way
你需要这样添加NSLocationAlwaysAndWhenInUseUsageDescriptioninInfo.plist
<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>
回答by Matthew Weldon
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]"
“[APIModule][设置][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
因此,该设置所针对的模块是应用程序的“NSLocation”调用,该设置与用户位置首选项的“始终和使用时”设置有关,而 KeyType 是“使用说明”,因此生成的键是
NSLocationAlwaysAndWhenInUseUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
or separated into the composite terms:
或分成复合词:
NSLocation
AlwaysAndWhenInUse
UsageDescription
NSLocation
AlwaysAndWhenInUse
UsageDescription