MapKit's UserAnnotation() fails with Error Domain=kCLErrorDomain Code=1 "(null)"

I replicated code in WWDC2023-10043: Meet MapKit for SwiftUI (https://developer.apple.com/videos/play/wwdc2023/10043/ ) and everything worked fine except showing user location with UserAnnotation() which starts at 23:24 of the presentation.

Xcode console displays the following error:

CLLocationManager(<CLLocationManager: 0x600000008630>) for <MKCoreLocationProvider: 0x600003014510> did fail with error: Error Domain=kCLErrorDomain Code=1 "(null)"

The same error happens even with code as simple as the below:

import SwiftUI
import MapKit

struct ContentView: View {
    var body: some View {
        Map() {
            UserAnnotation()
        }
    }
}

Error occurs with Preview, Simulator and iPhone device. Software being used are the latest beta versions: iOS 17 beta 5, Xcode 15 beta 6.

Post not yet marked as solved Up vote post of mikemjc Down vote post of mikemjc
877 views

Replies

In beta 7, you don’t get the error, but it doesn’t give me my location.

  • I am seeing this same problem when working with Xcode Version 15.0 (15A240d)

  • Am using 15.1, having the same problem. UserAnnotation() is not showing anything on Preview, Simulator, and Device as well. Thought it was a permissions problem, but didn't see any place to ask for permissions.

    (unless we initialize the show location button, which is an entirely different experience)

  • Have the same problem with MapUserLocationButton() in the section right after in the WWDC23 video. Same issue as UserAnnotation(), the button doesn't work on XCode 15.1