Use Plivo to automate Apple two-factor authentication
Apple authentication is necessary for UET to be able to download Xcode automatically and set it up. Unfortunately Apple two-factor doesn't work with TOTP codes; it only does 2FA over SMS and you can't turn 2FA off on Apple accounts.
There's basically two responses we can get from xcodes if it's going through authentication:
-
Apple ID: Missing username or a password. Please try again.: I think this happens if there's another authentication in progress (i.e. another machine or build job) for the same account. In this case, we need to just delay a random amount and try again. -
Enter the 6 digit code sent to +xx •••• ••• •xx:We need to pull the latest SMS message from Plivo and pass it into standard input.
The idea is you'd then set e.g. UET_PLIVO_PHONE_NUMBER and UET_PLIVO_API_KEY or something like that in addition to XCODES_USERNAME and XCODES_PASSWORD, and UET will do the hard work of pulling the SMS messages and going through Apple two-factor in an entirely non-interactive manner.
Due to the way .NET reads standard output from child processes on macOS, it's not possible to respond to the prompts that xcodes issues. The only way to move forward with this feature would be to re-implement xcodes entirely in C#, or have them add support for XCODES_GET_2FA_SMS_COMMAND as outlined here: https://github.com/XcodesOrg/xcodes/issues/311