I'm currently using this hack to get a reference to the underlying NSWindow:
Then this to set the aspect ratio:
Which gives the following log output:
Code Block func nsWindow(from window: UIWindow) -> AnyObject? { guard let nsWindows = NSClassFromString("NSApplication")?.value(forKeyPath: "sharedApplication.windows") as? [AnyObject] else { return nil } for nsWindow in nsWindows { let uiWindows = nsWindow.value(forKeyPath: "uiWindows") as? [UIWindow] ?? [] if uiWindows.contains(window) { return nsWindow } } return nil }
Then this to set the aspect ratio:
Code Block nsw.setValue(CGSize(width: 1.5, height: 1.0), forKey: "aspectRatio")
Which gives the following log output:
Before filing a feedback request, is there a more robust/approved method of doing this?WARNING: SPI usage of '-[UINSWindow uiWindows]' is being shimmed. This will break in the future. Please file a radar requesting API for what you are trying to do.