Xcode 9 - Info.plist中的位置使用说明 - iOS 11

xsc*_*der 1 location ios swift ios11 xcode9

我刚刚更新到Xcode 9.0正式版,当我运行使用位置服务的应用程序时,它工作正常但控制台打印出以下警告:

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
Run Code Online (Sandbox Code Playgroud)

所以我试图在我的Info.plist中添加以下密钥:

 <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>This app needs your current location</string>
Run Code Online (Sandbox Code Playgroud)

但是当我再次尝试运行应用时,Xcode 9会显示一条警告:无法读取数据,因为数据格式不正确.

所以我切换回:

<key>NSLocationAlwaysUsageDescription</key>
Run Code Online (Sandbox Code Playgroud)

该应用程序工作正常.哦,我的Info.plist已经包含了NSLocationWhenInUseUsageDescription键!

这是控制台中的Xcode 9错误吗?有人得到同样的警告吗?

xsc*_*der 5

没关系,我通过简单地浏览和选择Info.plist中的正确隐私 - 位置使用选项- >打开为 - >属性列表视图来修复它,这里是在需要时插入Info.plist的正确键:

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs your current location</string>

<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs your current location</string>
Run Code Online (Sandbox Code Playgroud)