'Editing a TextField in preview

I am trying to add a TextField in SwiftUI. It successfully appears with the initial text, but it is not editable in the preview display, only when I run a simulator. Any ideas?

@State var smth: String = "smth"
    
    var body: some View {
        //Not editable in preview
        TextField("Number", text: $smth)
    }


Solution 1:[1]

Since the comment was a legit answer I just copy paste it here. Glad it worked for you as well

There has been an Xcode bug in the past were live preview TextField input was broken. Seems to be back :(. I just experienced the same on 13.2.1. running the preview on iOS 15.2. switching to an iOS 14.3 simulator seems to fix it in my case. (wait for the Preparing iPhone Simulator for Previews to finish). Related to

Solution 2:[2]

I just download Xcode 13.3.1, and MacOs 12.4 Beta, and now I can use the physical keyboard for enter data in a TextField on a preview.I don't know if you can download only Xcode 13.3.1 without downloading the MacOs 12.4 Beta, or if Xcode 13.3.1 download alone resolve the problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Daniel Marx
Solution 2 Fortran programmer