MKErrorDomain 4 when performing a MKLocalSearch with an MKLocalSearchCompletion

Hi,

I have a controller where the user can search for map locations or points of interest by typing inside a search box.

To retrieve the list of results I set the queryFragment parameter of a MKLocalSearchCompleter with the search content. This correctly gives me back a list of MKLocalSearchCompletion of locations and points of interest.

When a user tap on one of this locations, I need to load the coordinates. In order to do that I do a MKLocalSearch passing the selected MKLocalSearchCompletion, like so:

let item = items[indexPath.row]
let request = MKLocalSearch.Request(completion: item)
let search = MKLocalSearch(request: request)
search.start { (response, error) in
   //Do stuff with the result.
   //For some specific items I receive an MKErrorDomain 4 error.
}

This works most of the time, but for some specific items the MKLocalSearch call return the error:

Error Domain=MKErrorDomain Code=4 "(null)" UserInfo={MKErrorGEOError=-8}

This error correspond to "placemarkNotFound", ie MapKit is not able to find a placemark for the specific MKLocalSearchCompletion. I just don't understant why this should be the case. The MKLocalSearchCompletion is returned by MapKit. If it is returned by MapKit then a corresponding placemark should exist, right? Why then is MapKit unable to perform a local search on it?

The problem now is that I present the user with a list of completions returned by MapKit but tapping some of them nothing happens because I cannot determine their respective coordinates.

Why is the search failing sometime? I miss something?

Thank you

Just want to add some new information.

I'm using the same exact code on two different apps and on the same device. With the exact same search term in one app I successfully receive an MKLocalSearch.Response but in the other one I receive an MKError.placemarkNotFound error. Why the same code, on the same device with the same search term but on different apps give a different result? The only notable difference between the apps is that the one that give the error is targeting iOS 15. The one that works is targeting iOS 13.

Please also note that I receive the error only for some particular search terms. These particular search terms always fails. Other search terms successufly return a valid MKLocalSearch.Response.

I receive the error on both physical device and simulator.

MKErrorDomain 4 when performing a MKLocalSearch with an MKLocalSearchCompletion
 
 
Q