Hi, I'm having a similar issue, the using MapKit the way it's done in the WWDC23 tutorial does not work (I'm using Xcode 14.3.1 also). I tried to solve my code using the answers above but using the deprecated initializers doesn't not work either.
After looking for hours on blogs and tutorial, it looks like the MapKit API got changed and possibly only working for iOS 17 using Xcode 15 Beta. But how on earth is anyone using MapKit to show a map for iOS 16 and previous versions now?
Here is my code below, along with the error messages I get:
import SwiftUI
import MapKit
struct MapView: View {
@State private var userTrackingMode: MapUserTrackingMode = .follow
@State private var region = MKCoordinateRegion(
center: CLLocationCoordinate2D(
latitude: 42.7878,
longitude: -74.9323),
span: MKCoordinateSpan(
latitudeDelta: 0.1,
longitudeDelta: 0.1))
var body: some View {
Map(coordinateRegion: $region,
interactionModes: MapInteractionModes.all,
showsUserLocation: true,
userTrackingMode: $userTrackingMode)
}
}
struct MapView_Previews: PreviewProvider {
static var previews: some View {
MapView()
}
}
Errors related to the the use of 'Map()':
Extra arguments at positions #1, #2, #3, #4 in call
Static method 'buildExpression' requires that 'Map' conform to 'View'
Can someone help to find a way to use MapKit on iOS 16, looks like all resources online are outdated or referring to iOS 17. Thanks!