DEV Community

Fré Dumazy
Fré Dumazy

Posted on • Updated on

Upload to TestFlight with Fastlane and 2FA

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 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.)

The 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_id value 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:

  skip_waiting_for_build_processing: true,
  apple_id: "123456789"
Enter fullscreen mode Exit fullscreen mode

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 :)

Top comments (6)

nickykln profile image

Thank you very much, you saved my day :)

toureholder profile image
Touré Holder

It also wasn't obvious to me that upload_to_testflight expects the app's apple id. Thanks for saving me a ton of time!

dumazy profile image
Fré Dumazy

You're welcome

zeepower profile image

Thank you Frederik, the only solution my search and revealed before this was the fast lane session. The negates the need for that!

amareis profile image
Иван Плесских • Edited

You are amazing man, this shit really pissed me off. Who decide to name this option just like as another, much more wide used term?..

I think it should be highlighted in docs.

dumazy profile image
Fré Dumazy

Glad I could help :)
Yes, they definitely could have avoided confusion by using a more explicit name...