-
-
Notifications
You must be signed in to change notification settings - Fork 0
Description
NSHostingSceneRepresentation, introduced in macOS 26, allows calling SwiftUI’s windows and other elements set in a Scene from AppKit. However, while Settings and WindowGroup set in the Scene can be invoked as expected using environment.openSettings() and environment.openWindow(id:) respectively, calling Window or WindowUtility doesn’t work. That is, the app just fails to open the desired window with the provided ID, and no error message or other feedback appears.
I expect that executing the openUtilityWindow(_:)action in the following code will display the UtilityWindow set in the scene. However, the window does not actually open.
@main
final class AppDelegate: NSObject, NSApplicationDelegate {
private let scene = NSHostingSceneRepresentation {
UtilityWindow("Utility Window", id: "UtilityWindow") {
Text("Utility Window")
.scenePadding()
}
}
func applicationWillFinishLaunching(_ notification: Notification) {
NSApp.addSceneRepresentation(self.scene)
}
@IBAction func openUtilityWindow(_ sender: Any?) {
self.scene.environment.openWindow(id: "UtilityWindow")
}
}Steps to reproduce
I’ve attached a minimal sample project named SceneWindowsApp that reproduces this issue.
A screen recording demonstrating the issue with this project is also attached.
- Open the attached sample project, SceneWindowsApp.
- Run the project.
- Select the File > Window Group to confirm the implementation works with normal WindowGroups.
- Select the File > Window or Utility Window to confirm this issue.
Here, we can confirm from the console debug messages that the IBAction is being called correctly and that the SwiftUI content view is indeed not being displayed.
Expected results
Sending .environment.openWindow(id: "WINDOW_ID") to the NSHostingSceneRepresentation instance opens Window or UtilityWindow set in the scene.
Actual results
No window appears by sending .environment.openWindow(id: "WINDOW_ID") to the NSHostingSceneRepresentation instance when the target window set in the scene is Window or UtilityWindow.
Environment
- macOS: Version 26.1 Beta (25B5042k)
- Xcode: Version 26.1 beta (17B5025f)