Error: Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs)
I do not seem to find the problem. if you know how I can fix it please help.
The error is on the: var body: some View { code
This is the code:
import SwiftUI
import MapKit
struct ContentView: View {
@StateObject private var controller = ContentController()
@StateObject private var parkingController = ParkingController()
@State private var selectedLocation: ParkingLocation? = nil
@State private var userLocation: CLLocationCoordinate2D?
private let locationManager = CLLocationManager()
var body: some View {
VStack {
Map(coordinateRegion: $controller.region, interactionModes: .all, showsUserLocation: true, userTrackingMode: $controller.userTrackingMode, annotationItems: parkingController.parkingLocations) { location in
MapMarker(coordinate: CLLocationCoordinate2D(latitude: location.latitude, longitude: location.longitude), tint: location.isAvailable ? .green : .red)
}
}
.ignoresSafeArea()
.gesture(
MagnificationGesture()
.onChanged { scale in
controller.zoom(scale)
}
)
.overlay(
HStack {
Spacer()
VStack {
Spacer()
Button(action: {
controller.toggleUserTrackingMode()
parkingController.updateParkingAvailability()
}) {
Image(systemName: "location.circle.fill")
.font(.largeTitle)
.foregroundColor(.blue)
.padding()
}
Menu{
Button("Cancel", role: .destructive){
}
Button{
}label: {
Label("Park Out", systemImage: "car.side.fill")
}
Button(action: {
if let userLocation = userLocation {
if let nearestLocation = parkingController.findNearestLocation(userLocation: userLocation) {
parkingController.decreaseAvailability(location: nearestLocation)
}
}
}) {
Label("Park In", systemImage: "car.side.fill")
}
Button {
//do something
}label: {
Label("Add parking", systemImage: "plus")
}
}
label : {
Label("", systemImage: "car")
.font(.largeTitle)
.foregroundColor(.blue)
.padding()
}
}
}
)
.onAppear {
controller.requestLocationAuthorization()
locationManager.delegate = controller
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
.onChange(of: controller.userLocation) { location in
userLocation = location?.coordinate
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.onAppear {
let controller = ContentController()
let locationManager = CLLocationManager()
controller.locationManager = locationManager
locationManager.delegate = controller
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
}
}
I tried to look at syntax and missing } but there are none.