- Published on
- Tested on Xcode 16.1
- 2 min read
> Keep the Software Keyboard Visible in iOS Simulators
Over the years I've seen UI bugs make their way into forms on many occasions because developers often test using the iOS simulators. When testing using the simulator, it is second nature to start typing on your physical keyboard to enter text into a field. Doing so automatically dismisses the software keyboard. When this happens, it can be easy to ship code where some UI elements are hidden under the keyboard when it pops up.
The solution I've found is to place this snippet somewhere that will be run once early in your app's lifecycle. I usually use applicationDidFinishLaunching. Doing so will allow you to type with the physical keyboard without dismissing the software keyboard, thus making it easier to make sure your UI is behaving properly.
#if targetEnvironment(simulator)
let selector = NSSelectorFromString("setHardwareLayout:")
typealias SetHardwareLayoutImp = @convention(c) (
UITextInputMode,
Selector
) -> Void
for inputMode in UITextInputMode.activeInputModes {
if inputMode.responds(to: selector) {
guard let imp = inputMode.method(for: selector) else {
continue
}
let function = unsafeBitCast(imp, to: SetHardwareLayoutImp.self)
function(inputMode, selector)
}
}
#endif
Entering some text with both the software and hardware keyboards.

// Continue_Learning
What's New in Swift 6.3 and 6.4
Swift shipped twice this cycle: 6.3 in the spring and 6.4 alongside Xcode 27 at WWDC. Module selectors, async defer, and task cancellation shields are the three changes you'll actually use.
WWDC 2026 Predictions Report Card: What Apple Actually Shipped
Before WWDC 2026 I wrote down predictions and never hit publish. Four months later, with iOS 27 out and iPhone Duo days away, it's time to grade them against what Apple actually shipped.
Xcode 27.1 Beta or Xcode 27.2 Beta: Which One Do You Need?
Apple is running two Xcode betas at once. Xcode 27.1 beta has the iPhone Duo SDK and simulator, while Xcode 27.2 beta has the 27.2 SDKs and new tooling. Here's what's in each, the known issues to watch for, and how to keep both installed.
// Subscribe to the newsletter
Get the latest Swift and SwiftUI tutorials delivered to your inbox. No spam, unsubscribe anytime.
By subscribing, you agree to our Privacy Policy.