I want to set the dimensions of a WindowGroup
to a specific size when running on visionOS. On iOS and maOS we have the .defaultSize
modifier for that. When building for visionOS, Xcode offers a slightly different modifier (with an additional parameter called depth):
.defaultSize(width: 200.0, height: 200.0, depth: 200.0)
However this does not seem to have any effect — the size of my window in the simulator remains the same, even after a fresh app install.
How can I set a WindowGroup
to a specific size on visionOS?
Controlling SwiftUI's Volume dimensions
This method you specified, sets a default size for a volumetric window.
By default, each parameter (width, height, depth) is specified in points, which translates to 1 millimeter for volumetric scenes at standard system scale. The size of a volumetric scene is immutable after creation. If you want to follow the RealityKit scene-size-paradigm, use the initializer's fourth
in
parameter that allows you to set the size in meters.For me, the following approach does the trick (read this post to see the content of a volume in my visionOS app).
Controlling visionOS Window dimensions
visionOS SDK Beta 2 (Xcode 15 Beta 5)
In second beta of visionOS, there are some improvements on 2D window's resizability issue. You can control a size of window that is less or equal to
2m X 1m
(but not greater than this size).visionOS SDK Beta 1
.windowResizability(..)
modifier and all the other resizing methods are unavailable in visionOS Beta 1 (Xcode 15 beta 4 and lower).You can find the identical question on the Developers Forums.