I recently (accidentally) turned on two-factor authentication (2FA) for an Apple account that we use to submit iOS builds to TestFlight via our CI pipeline. Because of this, our CI system could not longer upload new builds to TestFlight.
Looking at the Fastlane documentation for continuous integration, I saw there was a possibility to use application specific passwords that allow other systems to upload the iOS builds on your behalf.
So I generated an application specific password at appleid.apple.com and added it as environment variable
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD. However I wasn't able to get this working until I figured something out in the pilot documentation. It states:
pilot/upload_to_testflight can use an Application Specific Password via the FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD envirionment variable to upload a binary if both the skip_waiting_for_build_processing and apple_id options are set. (If any of those are not set, it will use the normal Apple login process that might require 2FA authentication.)
upload_to_testflight action in the
Fastfile was actually missing these two parameters, at least the
apple_id was missing here. After trying to add it, it still wasn't working, but now I got the following error message:
apple_idvalue is incorrect. The correct value should be taken from Apple ID property in the App Information section in App Store Connect.
I thought I have to specify the Apple account's email address as
apple_id, just like it is in a Fastlane's
Appfile, but this actually expects the app's apple id, for example
123456789, which can be found on App Store Connect. After changing my upload command to this, it finally used the application specific password from the environment variable and was able to upload the iOS build to TestFlight:
upload_to_testflight( skip_waiting_for_build_processing: true, apple_id: "123456789" )
I lost quite some time getting the uploads to work in a CI system for a 2FA account, so I hope I'm able to help somebody by posting this here. Let me know if this helped you :)