The keyword you're looking for is #available. Use an if-else block, not #if and #endif, putting the iOS 14 code in the else part of the block.
TextField("Username", text: $username)
if #available(iOS 15.0, *) {
.focused($focusedField, equals: .username)
}
else {
// Put the iOS 14 equivalent code here.
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: