Xcode 12 Beta and iOS 14: Weird Console Logs "Objc[5551]: Class ... Is Implemented in Both"

How do I update Xcode codes I can use iOS 14 functions?

Project -> Info -> iOS Deployment Target

here you can change deployment target to iOS 14.
Sample Image

SwiftUI: Error while using if #available while trying to build to iOS 13 and iOS 14 in Xcode 12 beta 2

Unfortunately i can reproduce this bug in Xcode 12 beta 4, so here a workaround. You can wrap iOS 14 code into AnyView and all will compile successfully. In this particular case you can use the ViewModifier to make code look more swifty.

struct ContentView: View {
var body: some View {
List {
Text("Cool!")
Text("Cool!")
}
.modifier(GroupedListModifier())
}
}

struct GroupedListModifier: ViewModifier {
func body(content: Content) -> some View {
Group {
if #available(iOS 14, *) {
AnyView(
content
.listStyle(InsetGroupedListStyle())
)
} else {
content
.listStyle(GroupedListStyle())
.environment(\.horizontalSizeClass, .regular)
}
}
}
}


Related Topics



Leave a reply



Submit