title: Define macOS window size using SwiftUI
body: <p>I'm using SwiftUI to develop a new macOS application and can't figure out how to define the window size. In the AppDelegate, the window size is defined as shown below:</p>
  
  <pre><code>// --- AppDelegate.swift ---
  
  import Cocoa
  import SwiftUI
  
  @NSApplicationMain
  class AppDelegate: NSObject, NSApplicationDelegate {
  
      var window: NSWindow!
  
  
      func applicationDidFinishLaunching(_ aNotification: Notification) {
          // Insert code here to initialize your application
          window = NSWindow(
              contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
              styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
              backing: .buffered, defer: false)
          window.center()
          window.setFrameAutosaveName("Main Window")
  
          window.contentView = NSHostingView(rootView: ContentView())
  
          window.makeKeyAndOrderFront(nil)
      }
  }
  </code></pre>
  
  <p>The ContentView is defined as follows:</p>
  
  <pre><code>// --- ContentView.swift ---
  
  import SwiftUI
  
  struct ContentView : View {
      var body: some View {
          VStack {
              Spacer()
              Text("Top Text")
              Spacer()
              Text("Bottom Text")
              Spacer()
          }
      }
  }
  </code></pre>
  
  <p>When I build and run the application, the window appears but it is not the correct size. It appears as roughly the size of the two text labels which is not the 480x300 size that is defined in the AppDelegate.</p>
  
  <p>How am I supposed to define window size for a Mac application when using SwiftUI?</p>