Hey Anton.Ye, I faced something similar and found a reliable fix. The issue happens because “Full Keyboard Access” on macOS and “Connect Hardware Keyboard” in the iOS Simulator conflict with Xcode’s UI test system. They cause key events (like Tab or arrow keys) to queue up and only fire after the test ends. Here’s how you can fix it:
Turn off Full Keyboard Access on macOS:
Go to System Settings > Accessibility > Keyboard > Full Keyboard Access, and turn it off.
Turn off Hardware Keyboard in the iOS Simulator:
In the Simulator menu bar, go to I/O > Keyboard and uncheck “Connect Hardware Keyboard”.
Use the Software Keyboard instead (mimics real iOS device behavior and avoids delayed input).
Also, in your UI test code, make sure to force focus before typing to avoid weird delays:
let textField = app.textFields["YourTextFieldIdentifier"]
XCTAssertTrue(textField.waitForExistence(timeout: 5))
textField.tap()
textField.typeText("Sample input")
If the keyboard or focus is still buggy:
XCUIDevice.shared.press(.keyboardDismiss)
textField.tap()
textField.typeText("Sample input")
This solved the delay and the “burst of focus changes” for me. Hope it helps!
Topic:
Accessibility & Inclusion
SubTopic:
General
Tags: