Rahul Sharma

Updating my SwiftUI app for Xcode 11 Beta 5

Few days ago, Apple released Beta 5 of Xcode 11. It includes some minor changes, and bug fixes.

Things changed

TabbedView is now renamed to TabView.



.listStyle(.grouped) is deprecated.

Now you will need to use .listStyle(GroupedListStyle())



.navigationViewStyle(.stack) is deprecated.

You will need to use .navigationViewStyle(StackNavigationViewStyle())



.textFieldStyle(.roundedBorder) is deprecated.

You will need to use .textFieldStyle(RoundedBorderTextFieldStyle())



BindableObject is deprecated.

  • BindableObject is now called ObservableObject.
  • ObjectBinding is now called ObservedObject.
  • willChange now becomes objectWillChange.


@Published

You can mark a variable as @Published in ObservableObject class. @Published variable automatically send updates when that variable is changed.

For example:

Earlier you did something like this:

var willChange = PassthroughSubject<Void, Never>()

var highScore: Int {
	willSet { willChange.send() }
}

Now, you can just do:

@Published var highScore: Int


SegmentedControl is deprecated.

Now, you will need to use Picker with .pickerStyle(SegmentedPickerStyle())



Text now has a default lineLimit of nil.

Text now wraps to multiple lines by default.



tapAction is deprecated.

.tapAction {} is now .onTapGesture {}



isPresented is deprecated.

@Environment(\.isPresented) is change to @Environment(\.presentationMode)



Length is deprecated.

Length is deprecated. Renamed to CGFloat



Identifiable is now part of Foundation.

So you no longer need to import SwiftUI in modal files.



Image now doesn't causes a crash.

Image() no longer causes a crash if it fails to find the image of that name. It now justs logs the warning in console.

Known Issues

  • Using Path causes the app to crash.
  • NavigationLink inside ScrollView doesn't works.
  • contextMenu on a View inside NavigationLink shows white card.
  • Tapping on contextMenu action causes app to crash.
Tagged with: