Limitation: The Appium method hideKeyboard() is known to be unstable when used on iPhone devices, as listed in Appium’s currently known open issues. Using this method for an iOS device may cause the Appium script to hang. Appium identifies that the problem is because - "There is no automation hook for hiding the keyboard,...rather than using this method, to think about how a user would hide the keyboard in your app, and tell Appium to do that instead (swipe, tap on a certain coordinate, etc…)"
Workaround: Following the advice of the Appium documentation - use Appium to automate the action that a user would use to hide the keyboard. For example, use the swipe method to hide the keyboard if the application defines this action, or if the application defines a "hide-KB" button, automate clicking on this button.