如何解决Swift 5:M1 芯片上 Xcode 12 中的 CoreLocation 错误
我只是尝试在我的应用程序的地图上显示用户位置。这是我的单视图控制器的代码
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController {
@IBOutlet weak var mapView: MKMapView!
fileprivate let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationManager.requestWhenInUseAuthorization()
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = kCLDistanceFilterNone
locationManager.startUpdatingLocation()
mapView.showsUserLocation = true
}
}
但是当我尝试将 showsUserLocation 设置为 true 时,我收到这样的错误:
2021-03-01 15:40:13.158237+0300 测试[3618:220718] [MKCoreLocationProvider] CLLocationManager(
因此,我尝试了诸如“将位置设置为自定义,而不是在模拟器中设置为无” 或“允许在方案选项中进行位置模拟”之类的解决方案“,没有任何帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。