diff --git a/macos/Sources/Helpers/Backport.swift b/macos/Sources/Helpers/Backport.swift index 3dcbaa0c0..0b6c61ac1 100644 --- a/macos/Sources/Helpers/Backport.swift +++ b/macos/Sources/Helpers/Backport.swift @@ -132,8 +132,19 @@ enum BackportNSGlassStyle { #endif } -/// Backported `TextField` that supports text selection on macOS 15/iOS 18 and up. The `selection` -/// has no effect on versions below macOS 15/iOS 18. +/// Backported `TextField` that supports text selection on macOS 26/iOS 18 and up. The `selection` +/// has no effect on versions below macOS 26/iOS 18. +/// +/// Although the API is available from macOS 15, we force it to be 26. Because on macOS 15, +/// SwiftUI will crash when deleting texts, even for this simple example. +/// +/// struct ContentView: View { +/// @State private var text = "" +/// @State private var selection: TextSelection? +/// var body: some View { +/// TextField("Search", text: $text, selection: $selection) +/// } +/// } struct BackportSelectionTextField: View { private let titleKey: LocalizedStringKey @Binding private var text: String @@ -150,7 +161,7 @@ struct BackportSelectionTextField: View { } var body: some View { - if #available(iOS 18.0, macOS 15, *) { + if #available(iOS 18.0, macOS 26, *) { TextField( titleKey, text: _text,