How to build ios app in non interactive mode (CI) with 2 factor authentication

Can you tell me how to use expo build:ios command in a CI environment

So far I’m running:

expo build:ios --non-interactive --no-wait --release-channel=test --apple-id=XXXXX --team-id=F7NE7X9ZFW

And the build fails as it requires 2 factor authentication:

- Making sure project is set up correctly...
[16:43:00] Checking if there is a build in progress...
[16:43:00] Trying to authenticate with Apple Developer Portal...
Two-factor Authentication (6 digits code) is enabled for account 'XXXXX'
More information about Two-factor Authentication: https://support.apple.com/en-us/HT204915
If 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
...
Please enter the 6 digit code:
[16:43:02] Authentication with Apple Developer Portal failed!
[16:43:02] Reason: Unknown reason, raw: "The input stream is exhausted."

I’ve followed the link “If 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” but it seems these instructions aren’t coming from expo and I couldn’t find FASTLANE_SESSION mention along expo anywhere…


  Expo CLI 3.13.1 environment info:
    System:
      OS: Linux 4.19 Debian GNU/Linux 9 (stretch) 9 (stretch)
      Shell: 4.4.12 - /bin/bash
    Binaries:
      Node: 10.14.2 - /tmp/yarn--1583528604996-0.7470574996079646/node
      Yarn: 1.22.0 - /tmp/yarn--1583528604996-0.7470574996079646/yarn
      npm: 6.4.1 - /usr/local/nvm/versions/node/v10.14.2/bin/npm
    npmPackages:
      @storybook/react: ^5.3.13 => 5.3.13
      @storybook/react-native: ^5.3.9 => 5.3.9
      expo: ~36.0.0 => 36.0.2
      react: ~16.9.0 => 16.9.0
      react-native: https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz => 0.61.4

I’ve also asked on stackoverflow with more details: https://stackoverflow.com/questions/60566559/can-you-use-expo-buildios-on-a-ci-environment-with-apple-2-factor-authenticat

I’ve posted my solution on the slack overflow thread: https://stackoverflow.com/questions/60566559/can-you-use-expo-buildios-on-a-ci-environment-with-apple-2-factor-authenticat

Basically we run expo build:ios --clear-credentials locally with flags for all the necessary certificates, re-authenticated. And then on the CI pipeline we’re running expo login --non-interactive -u XXX followed by expo build:ios --non-interactive --no-wait without providing any apple credentials and it’s working so far

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.