Hey guys, this is my code:
import SwiftUI
import MapKit
import CoreLocationUI
struct ContentView: View {
@StateObject var vm = ViewModel()
var body: some View {
VStack {
Text("location")
LocationButton(.currentLocation) { vm.reqestUserLocationOnce() }
.foregroundColor(.white)
.symbolVariant(.fill)
.labelStyle(.iconOnly)
.clipShape(Capsule())
}
}
}
class ViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
private let locationManager = CLLocationManager()
override init() {
super.init()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
}
func reqestUserLocationOnce() { locationManager.requestLocation() }
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let currenLocation = locations.last else { return }
CLGeocoder().reverseGeocodeLocation(currenLocation) { placemarks, error in
guard error == nil else { return }
guard let placemark = placemarks?.first else { return }
guard placemark.location?.coordinate != nil else { return }
}
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { print(error.localizedDescription) }
}
And then I have 2 String Files in English and Hebrew:
English:
/*
Localizable.strings
*/
"location" = "Location:";
Hebrew:
"location" = "מיקום:";
So, if you make a project with my code and the String file in English, everything works fine.
But then try to add the Hebrew String file snd see how it crashes. Bummer.
Does anyone know why? Is it a swift or Xcode bug?
I have no Idea.