iOS Simulator Keyboards on Buddybuild
At work we use Buddybuild for continuous integration, running our tests and shipping builds to iTunes Connect for TestFlight. On the whole we’ve had pretty good experiences with their service. (The only CI service I’ve used that I like more is Codeship. I love Codeship, but iOS isn’t part of their setup. We use their service for all our server code.)
I was recently doing the annual new-Xcode-new-Swift dance, and found that some of our UI tests were failing. These ones were the tests that interact with the iOS on-screen keyboard, and they were failing in a way consistent with the simulator acting as having a hardware keyboard attached—that is, the software keyboard wasn’t visible when the tests expected it to be.
After a bit of a chat with Buddybuild support and a bit of digging around with Google, I’ve
added the following to our post-clone build script (buddybuild_postclone.sh
):
# make sure the simulator doesn't have a hardware keyboard connected
xcrun simctl shutdown all
defaults write com.apple.iphonesimulator ConnectHardwareKeyboard 0
The first command closes any running simulators in the environment, to make sure that they’ll start up again and so let the second command take effect, which writes a defaults key and value to tell the simulator to not use the hardware keyboard.
And now all our UI tests are passing reliably again. Simple, once you know the options are there.