I had a very similar odd issue with my app failing only in macOS with compile time error in Xcode 15.4:
Thread 1: Fatal error: No Observable object of type MyClass found. A View.environmentObject(_:) for MyClass may be missing as an ancestor of this view.
It seems that like you, I had to reinject the object in the view hierarchy - apparently because the view in fullScreenCover would otherwise not inherit the view when running on macOS
var body: some View {
TabView {
...
}
.fullScreenCover(isPresented: $shouldShowMyView) {
MyView()
.environment(myClassInstance)
}
}
Your post helped me resolve the issue - thank you!
FB13851806 (.fullScreenCover closure content does not inherit environement)
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: