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:

Same issue for me, running on iOS 17 (iPhone 14 Pro Max), iOS 16 (iPhone X), and iOS 17 Simulators. Using Xcode 15.0.1

+1 The same issue. React Native project: xCode 15, ios 17, simulatore. Real device is passed this.

+1, I'm having the same issue with iOS 17, Xcode 15.0.1, SwiftUI and TextField

Work fine with iOS 16

+1, I'm having the same issue

Not sure if this will help some but for me I was getting this message with a WKWebView that was editable when trying to show the keyboard. It was looping endlessly. I finally managed to remove the error and use the keyboard by removing an environment variable that I had in the view that contained the WKWebView Representable. It was the following @Environment(.colorScheme) var colorScheme. Commenting this out removed the problem.

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)

Hey Guys,

POTENTIAL WORK AROUND FOR THOSE TESTING ON PHONE:

Chiming in from left field after getting this error: -[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:] perform input operation requires a valid sessionID. inputModality = Keyboard, inputOperation = <null selector>, customInfoType = UIEmojiSearchOperations.

If you are just simply trying to run your app on a physical device, push the updated code to your phone (hitting the play button in Xcode). You will automatically enter the app on your device however, close out of the app entirely (swiping up on the app so it's basically not running in parallel with what you see in Xcode). Then re-enter the app (you won't get debugging features) and the app should work fine. Again, if you are simply trying to test on physical device, that is what worked for me. Let me know if it helps.

Ten months in on this thread and 24k people watching. Anyone have a solution to this yet? It's really hard to debug when our tools are broken and Apple doesn't visit the developer forums anymore.

Hello Guys, This issue is still there in 2024, any resolution?

Using TextField in an .alert() and this bug seems to be preventing the OK button from executing:

.alert("New Category", isPresented: $showNewCategoryNameAlert) {
    TextField("Enter Name", text: $userNewCategoryName)
    Button("OK", action: {
        print("Clicked OK")
        addCategory(newName: userNewCategoryName)
        userNewCategoryName = ""
    }).disabled(userNewCategoryName.isEmpty)
    Button("Cancel", role: .cancel) { }
  • Enter Name
  • Tap OK - dismisses
  • Print statement and addCategory don't run

BUT! Launch the .alert() again and click OK, everything executes. This issue is not present in iOS 18. Open to ideas for a work around!

iOS17 UITextView inputView becomFirstResponder does not work
 
 
Q