Seems that xcode has trouble lint/type checking inside closures. I was building the below view and made some typos, then my macbook started overheating due to xcode and could not get proper lint errors.
struct ContentView: View {
let astronauts: [Astronaut] = Bundle.main.decode("astronauts.json")
let missions: [Mission] = Bundle.main.decode("missions.json")
var body: some View {
NavigationView {
List(missions) { mission in
NavigationLink(
destination: Text("Detail View"),
label: {
Image(mission.image)
.resizable()
.scaledToFit()
.methodThatDoesntExit()
.frame(width: 44, height: 44)
VStack(alignment: .leading) {
Text(mission.displayName)
.font(.headline)
Text(mission.formattedLaunchDate)
}
})
}
.navigationTitle("Moonshot")
}
}
}
This will will throw a generic error instead of telling me .methodThatDoesntExit() doesn't exist.
The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions One solution is to create a separate item view and provide that in the closure, then everything works as expected.