shouldChangeCharactersIn called twice on simulator

After update on Xcode Version 14.3 (14E222b) all functions shouldChangeCharactersIn are called twice. I've checked all sources and even new projects are with the bug

I'm experiencing the same problem. However works fine on the colleague's laptop. The only difference is the laptop model "MacBook Pro 16-inch, 2019" (does not work correctly) and "MacBook Pro 16-inch, 2021"(works fine)

As a "workaround" could be used Combine by using publisher for the ".editingChanged" event.

Same problem here. XCode 14.3 & Macbook Pro 16" M1 Max. I hope this gets fixed asap, because otherwise the Simulator is unusable.

In my case empty space characters is being triggered as soon as I start typing, say for example if I type A then 'shouldChangeCharactersIn' will be called once for A and then second time for empty space. This is happening only in iOS 16.4 simulator and Xcode 14.3. Working fine with other iOS simulators and devices.

The Same problem here is that calling textField.text will now also call shouldChangeCharactersIn

I have same issue.

I'm calcularing final text in shouldChangeCharactersIn. For example, current text is "1234". I enter "5" in text field. Result text after first call of shouldChangeCharactersIn is "12345". Result text after second call of shouldChangeCharactersIn is "1234".

And one more thing. Notification "textDidChangeNotification" is sent correctly. Only once with final text is "12345".

Same issue, wasted like 2/3 hours on this. Dosen't work on simulator as expected but works fine on real device.

Same issue in Simulator (Rosetta) with Xcode 14.3, MacBook Pro M2 Max :/

same issue here, on xcode15 simulators, makes it almost impossible to test on simulator, has anyone filed a FB? im going to

Filed FB12258036

my issue is combination of Xcode 14.3 + iOS 16.4 simulator. Works fine for Xcode 14.3 + iOS 16.0 simulators. — jainygaurav less than a minute ago

Noticing this issue in iOS 17 using the Xcode 15 Beta as well.

Remove arm64 from excluded archs of your project build setting. Apple is no longer fixing x86_64 simulator issues.

When running an app from a build with NativeScript the TextField character inputs have the final character removed when using a simulator. I tried all of the suggested resolutions, but the problem hasn't been resolved. There are some workarounds on the javascript side, but it would be preferable if this was fixed by Apple.

Noticing this issue in iOS 17 Simulator using the Xcode 15 official release. Come on Apple! This is beyond ridiculous.

I had a fix using a debounce in Nativescript, but it fails to resolve the issue on the simulator. When I attempted to disable x86 architecture in the POD file, the build fails with a code of 65.

Still experiencing this issue in iOS 17.0.1 using Xcode 15.0.1. @tiredCoder Did apple ever respond to your filed issue?

Has anyone found solution for that problem?

Just to add my take. Just upgraded from Monterey to Sonoma to be able to run Xcode 15 SDK 17 as suggested by Apple for builds after April 24. All apps designed and built with Nativescript 8.6.1 now have Textfield issue when building on the command line. Building with Xcode 15 for arm64 (not x86) problem goes away. Makes building and testing in simulator very difficult.

Yes same here. Upgraded #Nativescript to 8.6.5 and Xcode 15.2 to get rid of the SDK version issues. Didn't have the issue with the previous version of XCode 14.x and Nativescript 8.6.1. Real ball ache to debug and test apps now.

It's fixed on XCode 15.3 when running the simulator for 17.4. Thank you.

I've found a workaround to this extra backspace character in 'shouldChangeCharactersIn' delegate. Keep in mind, this issue also affects the UITextViewDelegate method as well. The workaround is to return false from the method and just perform the manipulation of the text in there manually. Using this API, you can just get the output of the call and assign to self.text.

You will no longer see the extra call to 'shouldChangeCharactersIn' but you have to make the update to the text yourself by returning false. Hope this helps!

Objective-C example:

- (BOOL)textField:(UITextField *)textField
    shouldChangeCharactersInRange:(NSRange)range
                replacementString:(NSString *)string {
    NSString *    textBeforeChange = textField.text;
    NSString *    textAfterChange  = [textBeforeChange stringByReplacingCharactersInRange:range
                                                                          withString:string];

    [textField setText:textAfterChange];
    return NO;
}
shouldChangeCharactersIn called twice on simulator
 
 
Q