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.
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
Avcapturevideodataoutput Captureoutput Not Being Called
How to Draw a Cosine or Sine Curve in Swift
Change Webview Url from Appdelegate
Array as a Dictionary Value in Swift Language
Swift Covariant Generic Function:Placeholder Type Is a Subclass of Another
How to Read a Property List from Data in Swift 3
Suppressing Implicit Returns in Swift
If the Swift 'Guard' Statement Must Exit Scope, What Is the Definition of Scope
Nested Types in Swift - What Is the Good Practice
Uipickerview Selectrow Doesn't Works
Scenekit - Custom Geometry Does Not Show Up
Declare Array of Classes That Conform to a Protocol
Cannot Add Alamofire to Swift Project
Swiftui Coordinator Not Updating the Containing View's Property
Lazy Property Initialization in Swift
Is the Swift Divide "/" Operator Not Working or Have I Missed Something
Mutating Function Inside Class
How to Identify Uppercase and Lowercase Characters in a String with Swift