Restoring macOS window size after close using SwiftUI WindowsGroup

By default, on a macOS app using SwiftUI the window size is not restored after the window is closed.

Is there a way to keep whatever size & position the user gave before closing the app. Essentially I'd like close & open to behave in the same way to when the user quits & opens the app?

Is there something that should be added here?

import SwiftUI

@main
struct testApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

Thanks in advance!

Replies

Does not seem doable in SwiftUI as of macOS 12. Will see what's announced in the next WWDC.