SwiftUI changes in Xcode 11 Beta 3

Today release of Xcode 11 Beta 3 brings some change to SwiftUI components. I will highlight some obvious one, you can check the rest here.

NavigationView {
    List {
        Text("Hello World")
        NavigationLink(destination: Text("Detail")) {
            Text("Detail")
        }
    }
    .navigationBarTitle(Text("Navigation Title"))
}

Reference

PresentationLink(destination: Text("Present"), label: { Text("Popup") })

Reference

.tabItemLabel -> .tabItem

We can finally use SF Symbol here and we can init .tabItem with Image and Text directly without VStack.

TabbedView {
    Text("First")
        .font(.title)
        .tabItem { Text("First") }
        .tag(0)
    Text("Second")
        .font(.title)
        .tabItem {
            Image(systemName: "circle")
            Text("Second")
        }
        .tag(1)
}

Reference

New initializer for most views with label

Most SwiftUI views got a initializer accepting @ViewBuilder as a label which quite verbose for most case where we just need simple Text.

In this beta 3 those views get a new initializer which accept LocalizedStringKey.

Instead of.

Button(action: {
    print("Button tapped")
}) {
    Text("Button")
}

We can shorten it with.

Button("Button") {
    print("Button tapped")
}

You can checkout my compiled cheat sheet here.