Not able to type in textfield in iphone simulator using Mac Keyboard?

IphoneIpadIos7KeyboardIos6

Iphone Problem Overview


I'm working on a basic iOS app which supports both portrait and landscape modes. When the iPhone simulator keyboard is open in landscape and I'm switching the app to portrait mode I'm unable to type anything in any text field using my Mac physical keyboard.

Has anyone experienced this before? Is it a known bug?

Iphone Solutions


Solution 1 - Iphone

Found a great solution that worked for me.
Open simulator, then find menu Hardware -> Keyboard has three options:

  1. iOS uses same layout as OS X : This option disables the Mac keyboard
  2. Connect Hardware Keyboard : This option enables Mac keyboard but the keyboard will not show up.
  3. Toggle Software keyboard : This option will allow you type using your Mac keypad and will show the iOS on screen keyboard as well.

Solution 2 - Iphone

In Xcode 9 I faced the same problem with the iPhone 8+ simulator. I was able to solve it this way:

  1. Open ~/Library/Preferences/com.apple.iphonesimulator.plist file
  2. Find the problematic simulator identifier (shown in the Devices and Simulator window)
  3. Set CaptureKeyboardInput value to YES
  4. Restart the Simulator

Solution 3 - Iphone

From Simulator menu >> Hardware >> Keyboard >> Connect Hardware keyboard

OR

just press ⌘ + ⌂ + K

Solution 4 - Iphone

Before you start typing (when the on-screen keyboard shows up), press just the command key by itself and then release it. This should re-enable the keyboard in the simulator.

Solution 5 - Iphone

Launch iOS Simulator and enable Hardware > Keyboard > Connect Hardware Keyboard.

(You might have accidentally disabled it by pressing CMD + SHIFT + K - same shortcut as Clean in Xcode)

Solution 6 - Iphone

None of these suggestions worked for me. I closed the iOS Simulator app and restarted it. That fixed it for me.

Solution 7 - Iphone

On the Simulator try to change the device. Then run your app again on the original device. That worked for me.

If the first step alone doesn't work uncheck the option: iOS Uses same keyboard layout as OS X and then change the device.

I figured it out doing random stuff until it worked. Monkey fixing.

Solution 8 - Iphone

i think it is only because of a problem that you did not selected 'connect hardware keyboard option, on the simulator menu bar named 'Hardware'

Please follow the steps

Goto : Hardware -> Keyboard -> Connect Hardware Keyboard

Hope it will help you with the problem , Thank you.enter image description here

Solution 9 - Iphone

I am seeing the same problem. I believe the issue is related to the command key being "stuck" in the simulator if you rotate the device in the simulator using Command-LeftArrow and Command-RightArrow short cuts.

While we wait for Apple to fix, one way around this is to rotate the device by selecting the menu option instead of the keyboard shortcut. This rotates the device, and seems to leave the keyboard in a working state.

Solution 10 - Iphone

Repeating below command twice worked for me!!

> CMD+Shift+K

Solution 11 - Iphone

CMD + SHIFT + K

I have pressed this command 2 times to toggle and then it started working

Solution 12 - Iphone

I have just installed a new version of Xcode (5.0) and the keyboard in iOS Simulator didn't work on first launch. Just restarting the Simulator helped.

Solution 13 - Iphone

Its not a problem just Do these easy steps.

  1. Open Simulator

  2. Going To Top And you See Option Hardware click on this.

  3. When you click on Hardware some option appear and one option is Keyboard.

  4. Click on the Keyboard option and you see three option appear.

  5. If you want to use your mac button keyboard simple select 2nd option Connect Hardware Keyboard.

  6. If your want to use mobile tapping keyboard select 3rd option.

  7. 1st option is for those who select their keyboard through code.

Enjoy that all work.

Solution 14 - Iphone

For me, Select Simulator, Select Hardware -> Keyboard -> Connect hardware Keyboard.

It worked for me.

Solution 15 - Iphone

I just quit my simulator and it worked for me.

Solution 16 - Iphone

I just tried what you just said and it's true, it doesn't work if I move it to landscape and then to portrait again. It doesn't have any logic because my app is not even changing, and it works fine in the device, so it's a bug in the simulator.

You can report it to Apple using this:

https://developer.apple.com/bug-reporting/

Solution 17 - Iphone

I had problem with iPhone6 simulator i changed it to iPhone7.On iPhone7 i am able to continue my work.

Solution 18 - Iphone

XCode 12/13: In the simulator window, from the top pane, I/O>Input>Send Keyboard Input to Device

or alt-command-k

Solution 19 - Iphone

The solution that really work for me, was deleted the simulator and create new one. This bug I think that commonly occur when all shortcuts does not work from your keyboard to simulator.

Solution 20 - Iphone

Quit simulator and run following command in terminal:

rm ~/Library/Preferences/com.apple.iphonesimulator.plist

Solution 21 - Iphone

If your Mac keyboard is still disconnected after having all the options and settings correct, one cause is from rotating the device.

If you CMD + or to rotate device early when the simulator is starting up, the Mac keyboard will absolutely not work no matter what; changing menu settings does nothing! It might help to use the Mac keyboard to input inside the device before you rotate device.

Turning off "Send Menu Shortcuts to Device" and restarting the Simulator helps sometimes. I'll update if I get reliable, recreateable behavior.

I find the Mac keyboard works about half the time I run and quit Simulator. 50% ain't bad after all these years!?

Solution 22 - Iphone

I just restart the simulator and It worked for me.

Solution 23 - Iphone

Just use CMD+SHIFT+K and the keyboard will activate on it's own.

Solution 24 - Iphone

I met this problem whenever I rotate the simulator. Following the suggestions to change Hardware options does not work for me, neither reboot iOS Simulator.

I found a trick that click the editing area after rotation makes Mac keyboard end up work.

Solution 25 - Iphone

After doing so many stuffs, just a restart of my machine and enabling the below worked.

Enabling this in simulator: Hardware -> Keyboard -> Connect Hardware Keyboard

Solution 26 - Iphone

For Version 10.0 (SimulatorApp-851.2 CoreSimulator-518.19) with Xcode 9.3, nothing worked for me. I reset the simulator by Hardware -> Erase All Content and Settings -> Erase. Cleaned the project and run on simulator. Keyboard connection is back.

Solution 27 - Iphone

I ran into this problem after I removed Main.storyboard and created the main window in code. Reverting back to using Main.storyboard fixed it for me.

Solution 28 - Iphone

For me doing this worked on iPhone 8+ simulator iOS 11.2:

  1. Go to Menu -> Hardware -> Erase all contents and settings.
  2. Delete derived data from xcode. Xcode -> Preferences -> Locations -> Click on right arrow on left side of "Advanced" button.

Solution 29 - Iphone

for me, on simulator opened, in the menu of your mac, click Hardware and reach to keyboard option and select toggle software keyboard.as shown

Solution 30 - Iphone

There is a library for editing plist files called plistlib. Here is my code:

    import plistlib

    file_name = ('path/to/com.apple.iphonesimulator.plist')
    try:
        p = plistlib.readPlist(file_name)
        p["ConnectHardwareKeyboard"] = "NO"
        plistlib.writePlist(p, file_name)
    except:
        print("Failure")

This reads the plist file, changes the ConnectHardwareKeyboard value to No and then writes the new file to the same location. This works for me, but let me know if there is a better way to do it. I'm still new at coding.

Solution 31 - Iphone

For me this problem were coming by window initialisation from the SceneDelegate

in XCode 12, swift 5, minimum deployment target 14, Storyboard

I have used the code just same as below

 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    guard let _ = (scene as? UIWindowScene) else { return }
    let windowScene = UIWindowScene(session: session, connectionOptions: connectionOptions)
    self.window = UIWindow(windowScene: windowScene)
    setRootVC()
}

After this code written I was getting this issue, paste is working but Keyboard not showing anyhow also not worked Mac Keyboard

to fix this I have removed these lines

 let windowScene = UIWindowScene(session: session, connectionOptions: connectionOptions)
    self.window = UIWindow(windowScene: windowScene)

And the problem was fixed for me, now SceneDelegate looks like

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    guard let _ = (scene as? UIWindowScene) else { return }
    setRootVC()
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDeepak CarpenterView Question on Stackoverflow
Solution 1 - IphoneiosCuratorView Answer on Stackoverflow
Solution 2 - IphoneMahbub MorshedView Answer on Stackoverflow
Solution 3 - IphoneMeseeryView Answer on Stackoverflow
Solution 4 - IphoneEugene OsovetskyView Answer on Stackoverflow
Solution 5 - IphoneAttila HView Answer on Stackoverflow
Solution 6 - IphonePeqNPView Answer on Stackoverflow
Solution 7 - IphoneclopezView Answer on Stackoverflow
Solution 8 - IphoneFansad PPView Answer on Stackoverflow
Solution 9 - IphoneSimon GuestView Answer on Stackoverflow
Solution 10 - IphoneDhaval H. NenaView Answer on Stackoverflow
Solution 11 - IphoneTarun SeeraView Answer on Stackoverflow
Solution 12 - IphonestrahView Answer on Stackoverflow
Solution 13 - IphoneMuhammad ZeeshanView Answer on Stackoverflow
Solution 14 - IphoneMuhammad AsadView Answer on Stackoverflow
Solution 15 - IphoneVikash SinhaView Answer on Stackoverflow
Solution 16 - IphoneAntonio MGView Answer on Stackoverflow
Solution 17 - IphoneAshok RView Answer on Stackoverflow
Solution 18 - IphoneMostafa ElShazlyView Answer on Stackoverflow
Solution 19 - IphonekakashyView Answer on Stackoverflow
Solution 20 - IphoneRohan SanapView Answer on Stackoverflow
Solution 21 - IphonedruView Answer on Stackoverflow
Solution 22 - IphoneVed RauniyarView Answer on Stackoverflow
Solution 23 - IphoneUchenna NnodimView Answer on Stackoverflow
Solution 24 - IphoneAzulesView Answer on Stackoverflow
Solution 25 - IphoneEaswaramoorthy KView Answer on Stackoverflow
Solution 26 - IphoneAlvin GeorgeView Answer on Stackoverflow
Solution 27 - IphoneBenedict CohenView Answer on Stackoverflow
Solution 28 - IphonecryptView Answer on Stackoverflow
Solution 29 - IphonePreetham NTView Answer on Stackoverflow
Solution 30 - Iphonetyler hackettView Answer on Stackoverflow
Solution 31 - IphoneSazid IqabalView Answer on Stackoverflow