ios - 来自 CoreMotion.framework 的奇怪 #NullIsland 警告

标签 ios core-location core-motion

最近,我在 Xcode 日志中收到了很多来自 CoreMotion 框架的奇怪警告,与函数 getLocationForBundleID 相关。 :

[Client] {"msg":"#NullIsland Either the latitude or longitude was exactly 0! That's highly unlikely", "latIsZero":0, "lonIsZero":0}  
[Client] {"msg":"#NullIsland Received a latitude or longitude from getLocationForBundleID that was exactly zero", "latIsZero":0, "lonIsZero":0, "location":'28 5B E0 D7 EB 7F 00 00'}  
我没有看到我的应用程序有任何故障。所以也许这些日志可以忽略不计,但无论如何它们都很烦人。
我的问题是:
如何纠正潜在错误?
我怎样才能停止这些警告?

最佳答案

显然,如果属性 location 会记录此错误消息的 CLLocationManagerCLLocationManager 之前读取交付了第一个位置。
我的解决方案如下:
无论如何,我使用 CLLocationManager 的子类这允许我设置 location以编程方式进行测试的属性。
这是按如下方式完成的:

private var _location: CLLocation?
@objc dynamic override var location: CLLocation? {
    get { 
        let usedLocation = _location ?? super.location // Here the error is logged if no location has been delivered yet
        return usedLocation 
    }
    set {
        _location = newValue
    }   
}
这个子类现在有一个额外的属性
  var anyLocationDelivered = false  
设置true
    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        locationManager.anyLocationDelivered = true
    // …
  }  
现在 setter/getter
get { 
    guard anyLocationDelivered else { return nil }
    let usedLocation = _location ?? super.location
    return usedLocation 
}  
现在不再记录此错误消息。

关于ios - 来自 CoreMotion.framework 的奇怪 #NullIsland 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64952663/

相关文章:

ios - 我如何转至与当前 Controller 共享同一根 Controller 的另一个 viewController?

android - React Viro,点击很长时间触发释放

ios - 如何在我的 Swift 应用程序的其他地方使用 locationManager 函数的经度和纬度值

ios - 核心运动事件是否与核心位置有关

ios - CoreMotion 姿态引用框架

ios - Xcode 7.0.1 未知类

ios - startMonitoringSignificantLocationChange 不会调用 didUpdateLocations

iphone - (iOS)通过locationManager的多个通知:didExitRegion: when exiting a region

iOS CoreMotion - 计算高度差

ios - 简单单 View 应用程序上的 xcodebuild 中的代码符号错误