|
| 1 | +# macOS iPhone automation |
| 2 | + |
| 3 | +I am trying to find a way to fully control an iPhone from my Mac Mini running |
| 4 | +macOS. |
| 5 | + |
| 6 | +There solutions won't work for me: |
| 7 | + |
| 8 | +- Apple's XCUITest testing framework |
| 9 | + |
| 10 | + Won't allow to automate the entire operating system. |
| 11 | + Meant to support development and testing of own apps. |
| 12 | + Requires interacting with X Code. |
| 13 | + |
| 14 | +- 3rd party testing tools |
| 15 | + |
| 16 | + Require a supporting application installation on the target device, a |
| 17 | + developer certificate and/or a provisioning profile. |
| 18 | + Not meant for general automation. |
| 19 | + |
| 20 | +- iPhone Mirroring feature on macOS |
| 21 | + |
| 22 | + Doesn't provide programmatic control. |
| 23 | + Also, not available in Europe. |
| 24 | + |
| 25 | +- Switch Control feature on iOS |
| 26 | + |
| 27 | + Doesn't provide programmatic control. |
| 28 | + Could be used in conjunction with programmatic HID. |
| 29 | + |
| 30 | +- Jail-breaking the device |
| 31 | + |
| 32 | + It is a PITA and I don't want to do it. |
| 33 | + Also not immediately available following new iOS version releases. |
| 34 | + |
| 35 | +This is the solution I am working towards building at the moment: |
| 36 | + |
| 37 | +## The "read" side |
| 38 | + |
| 39 | +Use `libimobiledevice` and its `idevicescreenshot` utility to monitor the iPhone |
| 40 | +screen. |
| 41 | +Use an LLM or SAM to recognize UI landmarks and elements for coordinates. |
| 42 | + |
| 43 | +The landmark and element recognition could be improved with the use of Switch |
| 44 | +Control potentially because AFAIK it renders an outline over the active element. |
| 45 | + |
| 46 | +The virtual pointer displayed when a mouse is connected could also help anchor |
| 47 | +the UI element recognition logic. |
| 48 | + |
| 49 | +## The "write" side |
| 50 | + |
| 51 | +The only feasible solution seems to be to part a HID to the iPhone and have it |
| 52 | +emit keyboard and mouse events as appropriate. |
| 53 | + |
| 54 | +I was considering Handheld Scientific BT-600, but it doesn't seem to have a |
| 55 | +programmatic access option, the serial interface is only for configuration. |
| 56 | + |
| 57 | +Now I'm thinking of using a Raspberry Pi Zero W and have it be powered off the |
| 58 | +controlling Mac Mini with a firmware that uses wi-fi to expose a programmatic |
| 59 | +interface and accept commands to translate to HID events for keyboard and mouse |
| 60 | +movement to send to the iPhone paired over BLE. |
| 61 | + |
| 62 | +Switch Control could play some sort of a role here to make the navigation work |
| 63 | +more reliably by automatically switching among landmarks etc. |
0 commit comments