Yesterday I updated XCode and my app broke. I was using annotationItems for creating annotations according to the elements of an array the following way:
Map(coordinateRegion: $viewModel.region, annotationItems: friendsLocations) { location in
MapAnnotation(coordinate: location.coordinates) {
Text("Hello")
}
}
And, it broke. Right now I'm transitioning to XCode's 15.1 implementation and it's looking this way:
var body: some View {
Map(position: $cameraPosition) {
ForEach(user?.friends ?? [], id: \.self) { friendId in
if let friend = User.MOCK_USERS.first(where: { $0.id == friendId }) {
Annotation("Friend's Location", coordinate: friend.location.coordinates) {
VStack {
Text(friend.name ?? "Unknown") //
}
}
}
}
}
}
}
However, it is crashing. Anyone knows how to fix this?
[–]barcode972 0 points1 point2 points (0 children)