• You can now place a TextField in an Alert by using alert modifiers that accept a ViewBuilder . (64819930)
I haven't tested it yet as I'm still using Monterey, but it should work according to the release notes.
If you are looking for macOS 12 and earlier solutions, you can do something like this:
Button("Tap Me") {
let alert = NSAlert()
alert.messageText = "Alert with text field"
alert.addButton(withTitle: "OK")
// You can customise this text field, this is just an example.
alert.accessoryView = NSTextField(string: "Text")
alert.runModal()
}