[quote='838899022, DTS Engineer, /thread/783804?answerId=838899022#838899022']
Are you referring to Sheet or windows?
[/quote]
Well, in AppKit I can present an NSViewController as a sheet via NSViewController.presentViewControllerAsSheet or I can present an NSWindow via NSWindow.beginSheet...
When using NSWindow, I have easy access to NSWindow.frameAutosaveName which, if set before the NSWindow is presented as a sheet, will restore it's size. If I use NSViewController, I have to grab the window in something like viewWillAppear, but that does work.
In the end, I ended up a bridged solution that does the following:
Embeds the SwiftUI view that should be presented as a sheet inside an NSHostingController.
Create a new NSWindow with the hosting controller as the contentViewController.
Configure the NSWindow as appropriate and then present as a sheet through AppKit.
It took quite awhile to get it right, but in the end the secret sauce was setting NSHostingController.sizingOptions to .intrinsicContentSize.
There's still an issue with NSWindow resizing when its contentViewController is set, but I think that's been an AppKit issue for awhile. It's more reliable to just add the view to the NSWindow's contentView instead, otherwise the NSWindow resizes to the initial size of the hosting controller.
But for now, it appears to be working. I suspect I'm pushing my luck a little bit because the actual view hierarchy is:
NSWindow.contentViewController -> NSHostingController
NSHostingController -> NSViewControllerRepresentable
NSViewControllerRepresentable -> NSSplitViewController
NSSplitViewItems -> SwiftUI Views
VSplitView and HSplitView don't appear to remember their positions at all. NSSplitViewController does, hence the need to use it instead. But NSSplitViewController's splitViewItems were wreaking havoc with a resizable sheet. Intrinsic content size appears to have resolved that issue.
Ultimately, it's three SwiftUI views hosted inside an NSSplitViewController which is presented as a resizable sheet.