gpt4 book ai didi

ios - NSLocationWhenInUseUsageDescription 错误一直显示

转载 作者:行者123 更新时间:2023-11-28 07:41:17 26 4
gpt4 key购买 nike

我尝试在我的项目中实现 MapKit 和 CoreLocation。不幸的是,错误不断出现

This app has attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSLocationWhenInUseUsageDescription key with a string value explaining to the user how the app uses this data

所以这是我的代码和 info.plist

import Foundation
import CoreLocation
import MapKit

class ViewController: UITabBarController, CLLocationManagerDelegate{

let locationManager: CLLocationManager = CLLocationManager()

@IBAction func backBarButton(_ sender: Any) {
self.dismiss(animated: true, completion:nil)
}


override func viewDidLoad() {
super.viewDidLoad()

locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
}

以源代码info.plist形式打开

<key>NSLocationWhenInUseUsageDescription</key>
<string>accept to get location</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>description</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>description</string>
<key>NSLocationUsageDescription</key>
<string>description</string>

打开 .plist 作为属性 View

enter image description here

I tried to create a new project and it works smoothly, however when I tried to implement this on my existing project it doesn't work.

最佳答案

从 iOS 11 开始,您不能在不提供“使用时”的情况下请求“始终”:如果您仅设置隐私 – 位置始终使用说明,它不会出现,并且您会收到错误消息“信息。 plist 必须同时包含 NSLocationAlwaysAndWhenInUseUsageDescriptionNSLocationWhenInUseUsageDescription 键……”。在 Xcode 9 beta 中,我必须使用 NSLocationAlwaysAndWhenInUseUsageDescription 键; Xcode 不会选择匹配的私钥。

位置经理要求“始终”:

click link for more description

关于ios - NSLocationWhenInUseUsageDescription 错误一直显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52177237/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com