Fastlane TestFlight app distribution without 2FA

Michał Międlarz
nomtek
Published in
2 min readApr 22, 2022

Never ever waste time on Two-Factor-Authorization setup on CI.

Photo by Markus Winkler on Unsplash

In my previous article (https://medium.com/nomtek/automatic-ios-app-deployment-with-bitrise-and-fastlane-4c1d93e631fc), I described basic Fastlane on Bitrise setup, which builds and releases apps on the Visual Studio AppCenter. Let’s take the next step and actually send our builds directly to App Store Connect!

Let’s start from adding new lane to the Fastfile:

There is no magic there, but I’ve added comments for those who are not familiar with Fastlane.

If we run the script now, it will ask for our account credentials and sometimes 2FA code, which is not exactly what we want. To skip providing it, we’re gonna use two Fastlane environment variables: FASTLANE_USER and FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD

The first one is straightforward as it’s just our email address from Apple ID. Second one is app-specific password — it can authorize us in some scenarios, and a session created with such a password has limited permissions.
Please create one (you can follow official instruction here: https://support.apple.com/en-gb/HT204397) and save it in a safe place.

Now open your terminal, navigate to the project directory, and call:

export FASTLANE_USER=your@email.com FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD=your-password && fastlane release_testflight

And that’s it! After some time needed to archive the app, Fastlane should upload it to App Store Connect without asking you for your real account credentials or 2FA code. It’s safe enough to be stored on CI and doesn’t require any extra actions, so you can configure and forget about it :)

--

--