Window default size

February 22, 2023

The default window size in this example is set to 400x200. If the window size is changed by dragging the corner or side, then the new size becomes the default size when the app is relaunched. Delete the app's container to restore the app to its default state.

// WindowDefaultSizeApp.swift

import SwiftUI

struct WindowDefaultSizeApp: App {
    var body: some Scene {
        WindowGroup {
        .defaultSize(width: 400, height: 200)
// ContentView.swift

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack {
            Image(systemName: "globe")
            Text("Hello, world!")
            Reset window to default size by deleting

window default size