- Using new concurrency swift model around CoreLocation
- Streaming current locations asynchronously
- Customizable in terms of accuracy
- Errors handling
@EnvironmentObject var model: LMViewModel
Task{
do{
try await model.start()
}catch{
self.error = error.localizedDescription
}
}
@ViewBuilder
var coordinatesTpl: some View{
List(viewModel.locations, id: \.hash) { location in
Text("\(location.coordinate.longitude), \(location.coordinate.latitude)")
}
}
///Status is not determined If you are trying to get Async stream without
permission request in case you implement your own ViewModel and access LocationManagerAsync.locations
case statusIsNotDetermined
///Access was denied by user
case accessIsNotAuthorized
public protocol ILocationManagerViewModel: ObservableObject{
/// List of locations
@MainActor
var locations : [CLLocation] { get }
/// Start streaming locations
func start() async throws
/// Stop streaming locations
func stop() async
}
if you are using the simulator don't forget to simulate locations
- You need to have Xcode 13 installed in order to have access to Documentation Compiler (DocC)
- Go to Product > Build Documentation or ββ§β D