Updating my SwiftUI app for Xcode 11 Beta 4
Yesterday, I update my SwiftUI app for 4th beta release Xcode 11. I thought Beta 4 will fix a lot of bugs. But to my disappointment, Xcode 11 Beta 4 took one step backwards.
Code changed
.color has been depreciated.
You need to use .foregroundColor()
instead.
Both .presentation and PresentationLink have been depreciated.
Now you need create a @State
boolean variable, Button which set that boolean to true as action, and .sheet(isPresented:)
@State var isShown: Bool = false
var body: some View {
Button(action: { self.isShown = true }) {
Text(“Tap me”)
}
.sheet(isPresented: $isShown) {
Text(“Destination View”)
}
}
BindableObject.
BindaleObject
now needs a willChange
instead of didChange
. Now the views are notified before the change is happened.
.identifiedBy() is depreciated.
ForEach(data.identifiedBy(\.self))
has been changed to ForEach(data, id: \.self).
Same for List
.
Known Issues
- NavigationLink nested inside a ScrollView which is inside a List doesn't navigates to the destination.
- For some reason, my app fails to find some images in the bundle.
Workround:
Image(uiImage: UIImage(named: imageName)!)
works
- Text inside ScrollView doesn't extends to multiple lines even after setting .lineLimit(nil)
- NavigationBar has a transparent background.