Using a Raspberry Pi for iPhone Switch Control
Background
If a user enables Accessibility Switch Control on an iOS device, one or more external switches can operate it.
A user can pair a bluetooth keyboard to a phone, and any keyboard key can as a switch.
Manual test
I connected my phone to a bluetooth keyboard and used one key to end a phone call by tapping the red end call button.
Proposed automated test system
A Raspberry Pi or microcontroller such as an Adafruit feather can act as a bluetooth keyboard emulator.
It could programmatically control a phone.
XCUITest could communicate with the emulator through a web service or WebSocket or similar.
I may prototype this in the future.
Advantages
- This approach is very general, could be applied to many actions.
- Doesn't require any wired electrical connection to phone
Disadvantages
- Requires some hardware
- Probably requires a moderate amount of work to implement.
- Multiple switch control action sequences may be a little cumbersome to program and synchronize with XCUITest.
References
Use Switch Control to navigate your iPhone, iPad, or iPod touch
https://support.apple.com/en-us/HT201370
iOS Switch Control on a Budget using Bluetooth Keyboards
https://www.youtube.com/watch?v=qDOVPdX9BE0
Shows Adafruit feather