Post

Replies

Boosts

Views

Activity

Reply to Check if iOS 14 is available in SwiftUI body
I am experiencing this issue in Xcode 13.2.1 on an iOS 14.8.1 device. Take this simple custom ViewModifier which applies the appropriate non-deprecated capitalization modifier based on the OS. struct CapitalizationModifier: ViewModifier {   let shouldCapitalize: Bool       func body(content: Content) -> some View {     if #available(iOS 15.0, *) {       content.textInputAutocapitalization(shouldCapitalize ? .words : .never)     } else {       content.autocapitalization(shouldCapitalize ? .words : .none)     }   } } I found that the crash only happens when built in the release configuration, but not debug. Changing the Optimization Level in the Swift Compiler - Code Generation section of the target's Build Settings prevents the crash.
Dec ’21