MKLocalSearch.start returning undocumented MKErrorGEOError

MKLocalSearch.start is giving me MKErrorGEOError=-8 which is not documented in MKError.
  • This only happens in my CI machine!

  • This only happens when running the tests, the app code works fine

  • I tried enabling location services on macOS just in case, but it didn't work.

  • That machine shouldn't have any network requests/URLs blocked

What fixed for me was to add request.naturalLanguageQuery = "Venue", but I don't understand why, nor why this would fix an error that is happening in only 1 machine.

Does anyone have any information about this?

Here's some sample code:
Code Block
let request = MKLocalSearch.Request()
request.naturalLanguageQuery = "Venue" // this fixes it, but why?!
let ibereCamargoMuseumCoordinates = CLLocationCoordinate2D(latitude: -30.0777596,
longitude: -51.2477212)
let span = MKCoordinateSpan(latitudeDelta: 5, longitudeDelta: 5)
request.region = MKCoordinateRegion(center: ibereCamargoMuseumCoordinates, span: span)
if #available(iOS 13.0, *) {
request.resultTypes = .pointOfInterest
}
let localSearch = MKLocalSearch(request: request)
localSearch.start { response, error in
...
}


Here's some debugging output:
Code Block
(lldb) po error
Error Domain=MKErrorDomain Code=4 "(null)" UserInfo={MKErrorGEOError=-8}
(lldb) po error.userInfo
▿ 1 element
▿ 0 : 2 elements
▿ key : AnyHashable("MKErrorGEOError")
- value : "MKErrorGEOError"
- value : -8




If you're interested I asked this on Stack Overflow too.

According to the debug output you posted (Error Domain=MKErrorDomain Code=4) the error is MKError.Code.placemarkNotFound.

You can find the documentation for that error here: https://developer.apple.com/documentation/mapkit/mkerror/code/placemarknotfound

From the code you have posted it looks like what you are trying to achieve is to find points of interest in a given location, regardless of their names.

MKLocalSearch.Request is not designed for this type of task as it is built for searching using query strings.

MapKit provides another similar API, MKLocalPointsOfInterestRequest, which is specifically built for finding points of interest when you are not looking for a particular name.

You can find the documentation here: https://developer.apple.com/documentation/mapkit/mklocalpointsofinterestrequest/

This API is broken https://developer.apple.com/documentation/mapkit/mklocalpointsofinterestrequest/ and either returns MKErrorGEOError=-8 or returns invalid results.

I am using MKLocalPointsOfInterestRequest which takes a central point and radius (or a region) to find places of interest within this boundary. It seems, as written in the documentation, written specifically for this purpose. Yet I get the MKErrorDomain code=4 as well, either when run on a simulator or run on an actual device. As a test, I fed it the coordinates of landmark, expecting it to at least return that. Kind of disappointing.

I try to get nearby points of interest with following code.

 var results: [MKMapItem]
        let testLocation = CLLocation(latitude: 39.7282754913204, longitude: -121.83680282031702)
        let request = MKLocalPointsOfInterestRequest(center: testLocation.coordinate, radius: 100)
        request.pointOfInterestFilter = .init(including: [.cafe])
        let search = MKLocalSearch(request: request)
        do {
            let response = try await search.start()
            results = response.mapItems
        } catch let error {
            searchLogging.error("Search error: \(error.localizedDescription)")
            results = []
        }

But got following error message:

SpatialPlaceLookup ticket submission failed. Too many parameters: 1 max allowed: 0
Search error: The operation couldn’t be completed. (MKErrorDomain error 5.)
MKLocalSearch.start returning undocumented MKErrorGEOError
 
 
Q