Reset macOS Catalyst Window Size to Default Minimum Size at Every Launch

I am using following code to have a minimum size for my app, It looks something like this:


#if targetEnvironment(macCatalyst)
    func addWindowSizeHandlerForMacOS() {
        UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.forEach { windowScene in
            print("addWindowSizeHandlerForMacOS()")
            windowScene.sizeRestrictions?.minimumSize = CGSize(width: 800, height: 800)
            // windowScene.sizeRestrictions?.maximumSize = CGSize(width: 801, height: 1101)
        }
    }
#endif


I want to have same minimum size as the default size for every time my mac catalyst apps opens.


Every instance my app relaunch it should open in its minimum size width and height i.e. 800 by 800.

Replies

Did you try to put similar code into


    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { }

Can you showcase exact code with right options as I am not getting any help from autocomplete or online search...