We updated our CI machine to:
- macOS Monterey Version 12.0.1
- Xcode Version 13.1 (13A1030d)
We started to receive UITest failures with following error:
Testing failed:
MemoryLeaksUITests:
MemoryLeaksUITests-Runner (3507) encountered an error (The test runner failed to initialize for UI testing. If you believe this error represents a bug, please attach the result bundle at /Users/dev/Library/Developer/Xcode/DerivedData/MemoryLeaks-dduvihbyiuzwdnawggthtfwdgwks/Logs/Test/Test-MemoryLeaks-2021.11.05_13-43-58-+0300.xcresult. (Underlying Error: Timed out while enabling automation mode.))
The failure disappears if we enable UIAutomation for testmanagerd by providing password
However it's not one time action. This permission dialog still appears after some time during a day. We noticed it constantly appears after machine reboot.
Unfortunately it blocks us from using our CI machine as test runner.
There is no option(checkbox) to permanently enable(provide password) automation in this dialog. Also it's not possible to add it in Settings -> Security & Privacy -> Privacy - Automation.
Here is a sample project on GitHub to reproduce the issue.
Steps:
- Reboot machine
- Run in terminal
xcodebuild -target MemoryLeaksUITests -scheme MemoryLeaks test
I opened TSI for the issue and got reply from Apple DTS Engineer that resolves my issue:
The automationmodetool command line tool allows you to manage UI automation security preferences, see its man page for details. To resolve your issue, run the following command as a administrator on your machine:
automationmodetool enable-automationmode-without-authentication
To disable this mode, run the following command as a administrator on your machine:
automationmodetool disable-automationmode-without-authentication
Note that the man page shows leading dash in front of each of the above two commands, it is a bug. Please disregard it and use the commands as described above.