I have the following code snippet with a simple map and map reader that shows a pin on the map when the user selects a location
struct MapReaderTest: View {
@State private var loc: CLLocationCoordinate2D? = nil
var body: some View {
MapReader { proxy in
Map {
UserAnnotation()
if let loc {
Marker(coordinate: loc, label: { Text("Marker") })
}
}
.onTapGesture { position in
let position = proxy.convert(position, from: .local)
loc = position
}
}
}
}
This snippet compiles and works perfectly fine using Xcode version 16.4 building for iOS 18.0 and running on a device. This snippet also works for me when I build using Xcode 26 Beta and run in the canvas or simulator, however it does not work when I compile using Xcode 26 and run it on a physical device(I built and tested for both iOS 18.6 and iOS 26 Beta)
Has anyone else had a similar issue / have any ideas for work arounds?
Take a look through this other thread discussing some known issues and workarounds regarding the onTapGesture
modifier with a Map
.
— Ed Ford, DTS Engineer