Using TextField:text:selection crashes on macOS

I am trying out the new TextField selection ability on macOS but it crashes in various different ways with extremely large stack traces. Looks like it is getting into re-entrant function calls.

A similar problem is described on the SwiftUI forums with no responses yet.

Here is my simple example

struct ContentView: View {
  @State private var text: String = ""
  @State private var selection: TextSelection?
  
  var body: some View {
    TextField("Message", text: $text, selection: $selection)
      .padding()
  }
}

Setting text to a value like "Hallo World" causes an instant crash as soon as you start typing in the TextField.

Setting text empty (as in example above) lets you edit the text but as it crashes as soon as you commit it (press enter).

Any workarounds or fixes?

Answered by DTS Engineer in 805229022

There isn't a workaround for the issue at the moment. Please test on the latest beta build (macOS Sequoia 15.1 Beta 5) and verify if you're still able to reproduce the issue.

Also, please file a bug report via Feedback Assistant. Once you open the bug report, please post the FB number here for my reference.

If you have any questions about filing a bug report, take a look at Bug Reporting: How and Why?

There isn't a workaround for the issue at the moment. Please test on the latest beta build (macOS Sequoia 15.1 Beta 5) and verify if you're still able to reproduce the issue.

Also, please file a bug report via Feedback Assistant. Once you open the bug report, please post the FB number here for my reference.

If you have any questions about filing a bug report, take a look at Bug Reporting: How and Why?

Using TextField:text:selection crashes on macOS
 
 
Q