Strange #NullIsland warning from CoreMotion.framework

Viewed 3406

Since recently, I get in the Xcode logs a lot of strange warnings from the CoreMotion framework, related to function 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'}  

I do not see any malfunction of my app. So maybe these logs can be ignored, but they are annoying anyway.

My questions are:

How can I correct a potential error?
How can I stop these warnings?

3 Answers

Apparently this error message is logged if property location of a CLLocationManager is read, before the CLLocationManager delivered the very first location.

My solution is the following:
I use anyway a subclass of CLLocationManager that allows me to set the location property for tests programmatically. This is done as follows:

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
    }   
}

This subclass has now an additional property

  var anyLocationDelivered = false  

that is set true in

    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        locationManager.anyLocationDelivered = true
    // …
  }  

and the getter is now

get { 
    guard anyLocationDelivered else { return nil }
    let usedLocation = _location ?? super.location
    return usedLocation 
}  

Now this error message is no longer logged.

I was getting this same error when trying to get a user's location in an app. There were two things preventing me from getting a valid lat/long. The main issue I was having was that I was using a simulator and had to set the location manually. If you're using the simulator, go to XCode, click Debug --> Simulate Location, and choose a location. I also had to make sure the correct location permission keys were added to Info.plist. You're also probably already aware, but you'll know if any keys are missing from Info.plist because a separate error message will print out to the console above or below these lat/long error messages, and it will tell you which key is missing. So basically:

  1. Make sure you have all necessary location permissions accepted on the device/simulator being used to test the application.
  2. Once you have location permissions, set a location if using a simulator.

Not sure if this will help at all, but I hope it does. If you've already confirmed that these are not issues, I'm not sure what may be causing the issue in your case, but stepping through the parts of your code responsible for fetching the user location would probably be beneficial to see which link in the process is failing.

  1. The issue is likely that you ran your application on the simulator, which does NOT use your current location by default unless you manually change the simulation location in Debug, Simulate Location.
  2. To fix the issue, either simulate your current location (as stated above) OR run your application on your physical signed device, close the application completely, and then relaunch your application.
Related