Another strange happening in #macOS #SwiftUI

If I launch the app I'm testing in Instruments (hit the record button) the main window does not open! I have to click on the icon of the app on the doc to open the window.

Simplified SwiftUI code in question is something like this:

var body: some Scene {
Window(“name”, id: "main”) {
ContentView()
.onAppear {
// some stuff
}
}
}
}

// some stuff includes a message which is not logged when run under Instruments. No problem running in Xcode.

So what is different about Instruments?

#SwiftUI #Xcode testing and instrumentation oddity resolved. For reasons that are no longer relevant I was using Window instead of WindowGroup in the scene of a #macOS app. I change back to using WindowGroup and the “failed to open main window when running under instruments" issue went away. Also, the XCUITests that ran into a similar (same?) issue started working, too.