I'm getting the following error in my swift build targeting VisionOS 2.0 :
" 'defaultDisplay' is unavailable in visionOS "
TLDR : how do I specify an initial window position in visionOS? The docs seem to be off? - see below.
The docs say it is available, but it is not, or at least my XCODE (Version 16.0 ) is throwing errors on it :
https://developer.apple.com/documentation/swiftui/scene/defaultwindowplacement(_:)
I know apple is opinionated about window placement in visionOS, and maybe it will never be available, but the docs say it is in visionOS 2.0+ and it sure would be nice to be able to specify a default position toward the bottom of one's FOV, etc .
Side-note -- the example code in that doc also has the issue that "Window" is not available in visionOS ( WindowGroup is ).
example code -- barely modified from example code in doc :
var body: some Scene {
WindowGroup("MyLilWindow", id: "MyLilWindow") {
TestView()
}
.windowResizability(.contentSize)
.defaultWindowPlacement { content, context in
let displayBounds = context.defaultDisplay.visibleRect
let size = content.sizeThatFits(.unspecified)
let position = CGPoint(
x: displayBounds.midX - (size.width / 2),
y: displayBounds.maxY - size.height - 140)
return WindowPlacement(position)
}
}