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:

Facing same issue in production from users who updated to iOS 17, running with Xcode 15 also same issue. We are using wkwebview and js textfield, its crashing with below stack trace

Minmal reproducible example:

import SwiftUI

struct ContentView: View {
    @State private var text: String = ""
    @FocusState private var focused: Bool

    var body: some View {
        List {
            TextField("key", text: $text)
                .focused($focused)
            if (!focused) {
                Section {
                    Button("click") {
                        print("click")
                    }
                }
            }
        }
    }
}

For some reason, if I remove one of .focused($focused), if (!focused) { or Section, the error doesn't occur.

Hello there! I had the same error. In my case the problem was in a LazyVStack in which I had the TextField. I changed from LazyVStack to Stack and everything is fine. Probably this occur because of the resizing of the container.

Same issue here, but... i found a solution !

I tried to disable IQKeyboardManager for the classes where the problem appeared. And it worked !

I updated to IQKeyboardManagerSwift and its still OK.

Same error with Xcode 15.0.1. With some additional log:

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.
If you want to see the backtrace, please set CG_NUMERICS_SHOW_BACKTRACE environmental variable.

Please fix this problem.

I guess this is Apple speaking to Apple… 😉

This may be related to this post: https://developer.apple.com/forums/thread/738726 where the appearance of text magnification loupe, text selection pop ups or autocorrect suggestions cause the error.

+1

I am also seeing this - I am wondering if it's effecting a ToolbarItemGroup from displaying incorrectly - intermittently.

+1 -- same issue here as well.

+1, I'm having the same issue

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.

iOS17 UITextView inputView becomFirstResponder does not work
 
 
Q