mattiem, @donnywals hey Donny!
I just read your post here. I’m not sure using a runtime check (
Thread.isMainThread
) really makes sense here because isolation is determined at compile time. There is never ambiguity for correctly annotated APIs.Though I do agree that SwiftUI marking its body as MainActor but not the entire type is a poor API that makes it specifically hard to use.
https://www.donnywals.com/how-to-determine-where-tasks-and-async-functions-run-in-swift/