Im releasing my app to firebase distribution throw Fastlane while using CI machine.
Im facing an issue with the 2FA.
Im using Match to retrieve my certificates.
This is what I have under "Appfile"
app_identifier "com.example.example" # the bundle
apple_id "appleAcount@gmail.com" # Your Apple
team_id "abcd..." # Developer Portal Team ID
ENV["FASTLANE_USER"] = "appleAcount@gmail.com"
ENV["MATCH_PASSWORD"] = ""
ENV["FASTLANE_PASSWORD"] = ""
ENV["FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD"] = ""
This is the error I'm receiving:
Two-factor Authentication (6 digits code) is enabled for account
'appleAcount@gmail.com' More information about Two-factor
Authentication: https://support.apple.com/en-us/HT204915If you're running this in a non-interactive session (e.g. server or
CI) check out
https://github.com/fastlane/fastlane/tree/master/spaceship#2-step-verification(Input
sms
to escape this prompt and select a trusted phone number
to send the code as a text message)(You can also set the environment variable
SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER
to automate this) (Read more
at:
https://github.com/fastlane/fastlane/blob/master/spaceship/docs/Authentication.md#auto-select-sms-via-spaceship_2fa_sms_default_phone_number)Please enter the 6 digit code:
I have read this "https://docs.fastlane.tools/best-practices/continuous-integration/" but with no luck. can anyone help me solve this issue?
Best Answer
The fastlane team did a great job ❤ in recent releases (from 2.157.0 to 2.163.0 so far) to support the use of an API key for App Store Connect API in many actions (
pilot
,deliver
,match
, etc. - the status for each tool is available here).Using an API key removes the need to provide an Apple account to authenticate and authorize the fastlane actions to do their operations on App Store Connect, which also means that you will no longer be fighting with 2 factor issues on your CI machine or have to manually regenerate a session via
fastlane spaceauth
when it becomes invalid.From App Store Connect API Key page:
There are other benefits of using an API key and it is the recommended solution as explained in the fastlane documentation:
I will not detail the steps to set up and use an API key here as it is already well explained in the documentation but here are the main steps:
Fastfile
, call theapp_store_connect_api_key
action with the values stored in 2.api_key
parameter when you call an action, or let the action retrieve its value by itself from the lane context (if it supports it).2FA problem due to invalid session:
Should vanish :)