我刚刚更新到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
所以我尝试在Info.plist中添加以下密钥:
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs your current location</string>
但是当我再次尝试运行该应用程序时,Xcode 9会显示一条警告:无法读取数据,因为格式不正确。
所以我转回到:
<key>NSLocationAlwaysUsageDescription</key>
该应用程序运行正常。哦,我的Info.plist已包含 NSLocationWhenInUseUsageDescription 键!
这是控制台中的Xcode 9错误吗?有人得到同样的警告吗?
答案 0 :(得分:5)
没关系,我通过在 Info.plist - &gt;中浏览并选择正确的隐私权 - 位置使用选项来解决这个问题。打开为 - &gt;属性列表视图,这是在需要时插入Info.plist的正确键:
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs your current location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs your current location</string>