ios – SwiftUI TextField enter utilizing Siri dictation appends “u{0000fffc}”

[ad_1]

After I run a easy SwiftUI app on my gadget, and use Siri dictation to enter textual content right into a SwiftUI TextField, the textual content is typically appended by U000fffc. Xcode debugger console typically experiences cycles within the code.

ContentView.swift:

struct ContentView: View {
  @State var searchText = ""
  @FocusState var textFieldIsFocused: Bool

  var physique: some View {
    HStack {
      TextField("Search Textual content", textual content: $searchText)
      .targeted($textFieldIsFocused)
      .textFieldStyle(.roundedBorder)
      .border(Coloration.black)

      Button {
        guard searchText != "" else {return}

        // cover keyboard
        textFieldIsFocused = false

        print("enter: '(searchText)'  (searchText.rely) bytes ")
        let closing = searchText.removeTrailingNull()
        print("closing: '(closing)'  (closing.rely) bytesn")

      } label: {
        Textual content("Search")
      }
      .buttonStyle(.borderedProminent)

    }
    .padding()

  }
}

StringExtension.swift:

extension String {
  func removeTrailingNull() -> String {
    return self.replacingOccurrences(of: "u{0000fffc}" , with: "")
    }
}

I hit CMD+R To run this undertaking on my iPhone. After I choose the TextField, the keyboard seems as anticipated. Then the enjoyable begins…

The Good:

  1. If I sort utilizing the keyboard alphabetic keys, the whole lot runs as anticipated. Typing “Check” will present enter and closing strings of size 4 characters, as anticipated.

  2. If I press the microphone button on the keyboard, then say “take a look at”, then press the Search button to finish the dictation enter, the whole lot works as anticipated. “Check” is 4 characters on enter.

The Unhealthy:

  1. If I press the microphone button to begin Siri dictation, then say “take a look at” then press the waveform to point my voice enter is over, then press Search, the textual content is appended with “u{0000fffc}”. The searchText is 5 characters. Last is 4 characters after replacingOccurrences(of: with) does its work. That is sudden.

The Ugly

  1. If I do a Siri dictation AS THE FIRST TEXT ENTRY after operating the app, cycles are reported. This ONLY occurs once I finish dictation by urgent the waveform.

Xcode debugger show:

2022-07-05 14:42:56.002163-0700 SiriTest[3999:5142318] Steel API Validation Enabled
=== AttributeGraph: cycle detected by means of attribute 6016 ===
=== AttributeGraph: cycle detected by means of attribute 13424 ===
=== AttributeGraph: cycle detected by means of attribute 13424 ===
=== AttributeGraph: cycle detected by means of attribute 13424 ===
=== AttributeGraph: cycle detected by means of attribute 13424 ===
=== AttributeGraph: cycle detected by means of attribute 13424 ===
=== AttributeGraph: cycle detected by means of attribute 13424 ===
=== AttributeGraph: cycle detected by means of attribute 13424 ===

After setting a breakpoint, Xcode debugger exhibits once I sort “Pony”, closing isString “PonyU0000fffc”. That is the one method I knew what character was being appended

Is the appending of u{fffc} anticipated when ending a Siri dictation search by urgent the waveform? I do not see any comparable experiences in any SO articles.

What causes the cycle? Different SO solutions point out that is SwiftUI reporting a loop whereas attempting to render a view. This does not seemm associated to SwiftUI rendering because it happens after urgent the waveform to cease dictation enter.

MY setting

macOS Monterey 12.4
XCode Model 13.3.1 (13E500a)

I’m operating on my iPhone 8 Plus. That is an older cellphone that (I imagine)does NOT resolve Siri enter “on gadget” — I imagine it must ship audio packet to Apple. So is that this conduct gadget particular?

Bonus: Is there any loop/print that might mimic Xcode debugger exhibiting “PonyU0000fffc”

Any assist could be appreciated.

[ad_2]

Leave a Reply