Sam Doggett
Sam Doggett

Reputation: 530

MKMapItem's identifier is nil on physical device only

I have noticed a discrepancy between behavior on physical devices and simulators in iOS 18.

I am using the latest MapKit APIs to fetch MKMapItems using the following MKLocalSearch:

private func performLocalSearch(_ query: String) async throws -> [MKMapItem] {
    let request = MKLocalSearch.Request()
    request.naturalLanguageQuery = query
    let search = MKLocalSearch(request: request)
    return try await search.start().mapItems
}

This returns an array of MKMapItem on both the simulator and physical device. The key difference is my physical device (iOS 18.1.1) is missing the MKMapItem's identifier value. Any ideas on how to resolve this?

The new MapKit API for those curious:

@available(iOS 6.0, *)
open class MKMapItem : NSObject {

    @available(iOS 18.0, *)
    open var identifier: MKMapItem.Identifier? { get }

Upvotes: 0

Views: 55

Answers (0)

Related Questions