SwiftUI autocapitalisation for macOS and iOS targets

When writing for iOS, I can easily set the autocapitalisation for a TextField by using the .autocapitalisation view modifier. This takes a  UITextAutocapitalizationType and I often use the type .words for my TextField controls in iOS apps.

e.g.
Code Block
TextField("enter a name", text: $object.name)
.autocapitalization(.words)

Being a part of UIKit, this modifier is not available for macOS 11.

I am writing an app using SwiftUI for macOS and iOS targets.

I want to apply a view modifier to my universal app TextFields that works on both platforms.

I could write a function that iterates through every word and use the .textCase view modifier to change the first letter of each word but that seems like a lot of work and also very clunky.

Any ideas how to implement something like UIKit .autocapitalization(.words) using SwiftUI for a macOS target?

(Without resorting to UIViewRepresentable?)
SwiftUI autocapitalisation for macOS and iOS targets
 
 
Q