I have UI tests which testing login functionality (and uses it to test other stuff), but sometimes when focus is changed from one field to another - the keyboard hides, and
For Xcode 10.2, none of these solutions work for me, the plist is changed correctly but keyboard is till hidden. I have to use oascript to press Ctrl + Shift + K on Simulator if the keyboard is not displayed. It's not beauty but it's the only workaround that works.
tell application "Simulator" to activate
tell application "System Events"
keystroke "K" using {command down, shift down}
end tell