[WindowHosting] UIScene property of UINSSceneViewController was accessed before it was set. What does this mean?

Getting this error several times when presenting a modal window over my splitview window when running it on my Mac using Swift/Mac Catalyst in XCode 14.2. When I click the Cancel button in the window then I get Scene destruction request failed with error: (null) right after an unwind segue.

2023-07-04 16:50:45.488538-0500 Recipes[27836:1295134] [WindowHosting] UIScene property of UINSSceneViewController was accessed before it was set.
2023-07-04 16:50:45.488972-0500 Recipes[27836:1295134] [WindowHosting] UIScene property of UINSSceneViewController was accessed before it was set.
2023-07-04 16:50:45.496702-0500 Recipes[27836:1295134] [WindowHosting] UIScene property of UINSSceneViewController was accessed before it was set.
2023-07-04 16:50:45.496800-0500 Recipes[27836:1295134] [WindowHosting] UIScene property of UINSSceneViewController was accessed before it was set.
2023-07-04 16:50:45.994147-0500 Recipes[27836:1295134] Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7f7fdf068a00>.
bleep
2023-07-04 16:51:00.655233-0500 Recipes[27836:1297298] Scene destruction request failed with error: (null)

I don't quite understand what all all this means. (The "bleep" was a debugging print code I put in the unwind segue). I'm working through Apple's Mac Catalyst tutorial but it seems to be riddled with bugs and coding issues, even in the final part of the completed app which I dowmloaded and ran. I don't see these problems on IPad simulator.

I don't know if it's because Catalyst has problems itself or there's something else going on that I can fix myself. Any insight into these errors would be very much appreciated!

PS: The app seems to run ok on Mac without crashing despite the muliple issues

Without knowing the stack trace that emitted these logs its difficult to know what caused them, but I would recommend simply filing a feedback request about it at this time.

I'm getting the same error "UIScene property of UINSSceneViewController was accessed before it was set." 3 times in the console when I run the following targeting My Mac (Mac Catalyst). I do not get the error in the iPhone 15 Pro simulator or when running targeting My Mac (Designed for iPad) so I think it might be a bug.

struct ContentView: View {
    @State var testIsPresented = false
    var body: some View {
        NavigationView {
            VStack {
                Image(systemName: "globe")
                    .imageScale(.large)
                    .foregroundColor(.accentColor)
            }
            .toolbar {
                Menu("Test") {
                    Button("Show Sheet") {
                        testIsPresented = true
                    }
                }
                .sheet(isPresented: $testIsPresented) {
                    Button("Dismiss") {
                        testIsPresented = false
                    }
                }
            }
        }
    }
}

After some thought it seems that Catalyst reports this issue when presenting modal windows (such as a sheet) when running on a Mac vs running on iPad/iPhone, where modal windows are much more common. I'm guessing a Mac build is looking for an actual, separate scene (window).

This issue is irritating but seems innocuous, though.

My workaround for this in Mac build (in Swift) was to create a separate window scene that does what the modal window does, and present a normal modal window in iPad/iPhone, but that's only one solution.

You might also work around this in SwiftUI by using something like .overCurrentContext or .fullScreen for modalPresentationStyle if you don't want to mess with a separate scene. I'm not familar with SwiftUI so I'm not sure what you would do in your example.

Were you able to find a solution to this? Thank you

[WindowHosting] UIScene property of UINSSceneViewController was accessed before it was set. What does this mean?
 
 
Q