iOS17 UITextView inputView becomFirstResponder does not work

Simplely, when we set UITextView.inputView and then call becomeFirstResponder, but the custom inputView could not show expectedly just like before. We test this code in iOS17 and below, while only iOS17 does not work.

And xcode console print these logs:

Failed to retrieve snapshot. -[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:] perform input operation requires a valid sessionID -[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:] perform input operation requires a valid sessionID -[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:] perform input operation requires a valid sessionID -[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:] perform input operation requires a valid sessionID Unsupported action selector setShiftStatesNeededInDestination:autoShifted:shiftLocked: Unsupported action selector setShiftStatesNeededInDestination:autoShifted:shiftLocked: Unsupported action selector setShiftStatesNeededInDestination:autoShifted:shiftLocked: Unsupported action selector setShiftStatesNeededInDestination:autoShifted:shiftLocked:

I was struggling with the same error:

-[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:] perform input operation requires a valid sessionID

My workaround is using UITextFieldDelegate.

I created a new string variable in my view controller, and then set my text field's delegate to self.

class ViewController : UIViewController {

    private var textFieldText : String? = nil

    private var myTextField : UITextField = {
    //....... some code
    }()

    override func viewDidLoad() {
        //....... some code
        myTextField.delegate = self
    }
}

Then i set this new string to text field's text after editing ends with the delegate method.

extension AddToGalleryVC: UITextFieldDelegate {
    func textFieldDidEndEditing(_ textField: UITextField) {
        let text = textField.text
        textFieldText = text
    }
}

So i am using my new variable (textFieldText) instead of myTextField.text

Maybe an ugly solution but works for now.

In my case, it turned out to be a problem with the views getting recycled. I've implemented a TextField inside a ScrollView with LazyVStack in it, and when keyboard pops up, the scroll view shrinks and TextField leaves a rendering area and becomes unavailable then TextField loses focus. Switching to VStack solved problem.

iOS 17.2, Xcode Version 15.1 The problem has not yet been resolved.


-[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:] perform input operation requires a valid sessionID Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored. Please fix this problem.

I think that happens when you bind a value, and the screen continues to listen for value changes. After you open the view to edit the value on the screen, and when you edit it, the screen rebuilds. This either closes the view edit field or results in no response

.searchable SwiftUI on IOS 17 cause an error: -[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:] perform input operation requires a valid sessionID

Can confirm I am having the same issue, even after installing the latest XCode update today (Version 15.2 (15C500b)). iOS 17.2.1.

Warnings are logged with both the simulator and my iPhone 13 mini (17.2.1).

Removing all references to focusState does not fix.

same here on a very simple case.

I could ignore the warning, but the first focus is very very slow.

Same issue here

Same issue here. iOS 17, XCode 15.1 and 15.2. The app crashes when I use a lot of the .searchable() and select one item from the filtered list. I tried to disable .autocorrectionDisabled(true) but with no luck. I have this issue on production and I can't fix it yet. Any new approach?

In my case I was listening for keyboards notifications and making it part of the environment. For some reason this caused consternation with textfields in general nested deeply in views. This includes searchable(). I took it out of the environment and all was well. Quite obvious swiftui is still riddled with bugs.

Same issue and first focus is very slow.

Same issue here.

Same issue here.. .Though, first focus is only slow when attached to Xcode debugger. On real device, when disconnected, focus works normally.

This worked to temporarily solve, this problem only occurs in the emulator in my case.

Once the emulator is open, go to the option

I/O / KeyBoard and disable the connect hardware keyboard option

Then go to **I/O / Input ** and activate send keyboard input to device

I am getting this error too occasionally on a capacitor/ionic app on real iPhones (not simulator)

iOS17 UITextView inputView becomFirstResponder does not work
 
 
Q