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?
Found a great solution that worked for me. Open simulator, then find menu Hardware -> Keyboard has three options:
iOS uses same layout as OS X : This option disables the Mac keyboard Connect Hardware Keyboard : This option enables Mac keyboard but the keyboard will not show up. Toggle Software keyboard : This option will allow you type using your Mac keypad and will show the iOS on screen keyboard as well.
In Xcode 9 I faced the same problem with the iPhone 8+ simulator. I was able to solve it this way:
Open ~/Library/Preferences/com.apple.iphonesimulator.plist file Find the problematic simulator identifier (shown in the Devices and Simulator window) Set CaptureKeyboardInput value to YES Restart the Simulator
https://i.stack.imgur.com/c2kFY.png
From Simulator menu >> Hardware >> Keyboard >> Connect Hardware keyboard
OR
just press ⌘ + ⌂ + K
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.
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)
None of these suggestions worked for me. I closed the iOS Simulator app and restarted it. That fixed it for me.
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.
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
https://i.stack.imgur.com/iVpgG.png
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.
Repeating below command twice worked for me!!
CMD+Shift+K
CMD + SHIFT + K
I have pressed this command 2 times to toggle and then it started working
Its not a problem just Do these easy steps.
Open Simulator Going To Top And you See Option Hardware click on this. When you click on Hardware some option appear and one option is Keyboard. Click on the Keyboard option and you see three option appear. If you want to use your mac button keyboard simple select 2nd option Connect Hardware Keyboard. If your want to use mobile tapping keyboard select 3rd option. 1st option is for those who select their keyboard through code.
Enjoy that all work.
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.
I just quit my simulator and it worked for me.
For me, Select Simulator, Select Hardware -> Keyboard -> Connect hardware Keyboard.
It worked for me.
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/
I had problem with iPhone6 simulator i changed it to iPhone7.On iPhone7 i am able to continue my work.
XCode 12/13: In the simulator window, from the top pane, I/O>Input>Send Keyboard Input to Device
or alt-command-k
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.
Quit simulator and run following command in terminal:
rm ~/Library/Preferences/com.apple.iphonesimulator.plist
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!?
I just restart the simulator and It worked for me.
Just use CMD+SHIFT+K and the keyboard will activate on it's own.
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.
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
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.
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.
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.
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
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.
Success story sharing
I/O
>>Keyboard