supportsMultipleWindows
A Boolean value that indicates whether the current platform supports opening multiple windows.
Declaration
var supportsMultipleWindows: Bool { get }Discussion
Read this property from the environment to determine if your app can use the openWindow action to open new windows:
struct NewMailViewerButton: View {
@Environment(\.supportsMultipleWindows) private var supportsMultipleWindows
@Environment(\.openWindow) private var openWindow
var body: some View {
Button("Open New Window") {
openWindow(id: "mail-viewer")
}
.disabled(!supportsMultipleWindows)
}
}The reported value depends on both the platform and how you configure your app:
In macOS, this property returns
truefor any app that uses the SwiftUI app lifecycle.In iPadOS, this property returns
truefor any app that uses the SwiftUI app lifecycle and has the Information Property List key UIApplicationSupportsMultipleScenes set totrue.For all other platforms and configurations, the value returns
false.
If the value is false and you try to open a window, SwiftUI ignores the action and logs a runtime error.