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

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