您可以在 CI 环境中使用 "expo build:ios" 和 apple 2 因素身份验证吗?

Can you use "expo build:ios" on a CI environment with apple 2 factor authentication and how

有没有办法在 CI 环境中使用 expo build:ios 并通过 2 因素身份验证?

由于我的 Apple 开发者帐户需要 2 因素身份验证,我无法在我们的 CI 环境中使用 expo 开始构建。

expo build:ios 命令应该只在本地使用还是没有 2 因素身份验证?

运行 构建 locally 在交互模式下工作 - 仅在我第一次选择构建应用程序时才需要密码和 2 因素身份验证。对于连续构建,我只使用 expo build:ios --release-channel test 就是这样

我的 CI 环境是 google 的 Cloud Build - 它 运行 在 Docker 容器中,所以我不能去一次手动登录让 运行ner 保留一些会话信息,就像在本地发生一样,我可以吗?


阅读 expo build:ios 的 cli 使用信息后,您可以将帐户密码设置为 ENV 变量,如 EXPO_APPLE_PASSWORD 我认为应该可以在 CI 中使用它环境

但我得到以下结果:

expo login --non-interactive -u XXX

Success. You are now logged in as XXX.
expo build:ios --non-interactive --no-wait --release-channel test --apple-id XXXXX --team-id F7NE7X9ZFW
- 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."

所以我遵循 link 非交互式会话:https://github.com/fastlane/fastlane/tree/master/spaceship#2-step-verification

而且我看到我必须创建和使用 FASTLANE_SESSION 环境变量。 但那时我不确定它是否会起作用,因为它似乎来自 expo 内部使用的一些工具。

我想我可以在本地安装 fastlane 并尝试用命令 fastlane spaceauth -u user@example.org 生成这个变量。不过,我在世博会文档中没有找到任何相关内容

有关于使用 expo build:ios 构建独立应用程序的信息,它仅涵盖如何在本地构建它们 https://docs.expo.io/versions/v36.0.0/distribution/building-standalone-apps/

他们有一个 CI 流程指南 ("on Your CI") - 但它使用 turtle-cli 而对于 iOS 它需要 运行 mac 环境 - 它涵盖了如何在自己的 machine 上构建自己而不使用 expo.io https://docs.expo.io/versions/v36.0.0/distribution/turtle-cli/


我试过的另一件事是 运行宁喜欢:

expo build:ios \
  --team-id YOUR_TEAM_ID \
  --dist-p12-path /path/to/your/dist/cert.p12 \
  --provisioning-profile-path /path/to/your/provisioning/profile.mobileprovision

EXPO_IOS_DIST_P12_PASSWORD 设置为环境变量,但构建会失败,因为它仍然需要 apple id 和密码


有没有一种方法可以共享或复制我的本地会话 - expo 第一次创建的会话我 运行 build:ios 我已经过身份验证但没有提示我输入CI machine 密码了?

以下是最终对我有用的方法:

我创建了另一个包标识符 com.myawesome.stuff 我也 generated/created:

  • 分发证书 P12 --dist-p12-path
  • 按键 .p8 文件 - --push-id--push-p8-path
  • 配置文件。 - --push-p8-path

然后在本地我运行如下:

交互式登录

expo login

与 apple 交互验证

expo build:ios --clear-credentials --apple-id my@appleId.com --team-id=TheTeam --dist-p12-path=dist.p12 --provisioning-profile-path=profile.mobileprovision --push-p8-path=push.p8 --push-id=THEID --release-channel test

公平地说,我 运行 在本地但在 google 云控制台终端

然后在CI环境我们只使用:

expo login --non-interactive "--username=XXXX"
expo build:ios --non-interactive --no-wait "--release-channel=$BRANCH_NAME"

哪个有效并生成以下日志

- Making sure project is set up correctly...
[17:48:39] Checking if there is a build in progress...

[17:48:40] Fetching available credentials
[17:48:40] Unable to validate distribution certificate due to insufficient Apple Credentials
[17:48:40] Unable to validate Push Keys due to insufficient Apple Credentials
- Performing best effort validation of Provisioning Profile...

[xmldom error]  element parse error: Error: invalid tagName: 
@#[line:99,col:125]
[xmldom error]  element parse error: Error: invalid tagName: 
@#[line:114,col:75]
[xmldom error]  element parse error: Error: invalid tagName: 
@#[line:143,col:84]
✔ Successfully performed best effort validation of Provisioning Profile.
[17:48:40]
[17:48:40] Project Credential Configuration:
[17:48:40]   Experience: @XXXX/XXXX, bundle identifier: com.XXXXXXXX
[17:48:40]     Provisioning profile is missing. It will be generated during the next build
[17:48:40]     Apple Team ID: XXXXXXX,  Apple Team Name: ---------
[17:48:40]
[17:48:40]   Distribution Certificate - Certificate ID: -----
[17:48:40]     Apple Team ID: XXXXXXX,  Apple Team Name: ---------
[17:48:40]     used by
      @XXXX/XXXX (com.XXXXXXX)
[17:48:40]   Push Notifications Key - Key ID: XXXXXXXX
[17:48:40]     Apple Team ID: XXXXXXX,  Apple Team Name: ---------
[17:48:40]     used by
      @XXXX/XXXX (com.XXXXXXX)
[17:48:40] Unable to find an existing Expo CLI instance for this directory, starting a new one...
[17:48:42] Starting Metro Bundler on port 19001.
[17:48:46] Tunnel ready.
[17:48:46] Publishing to channel 'test'...
[17:48:47] Building iOS bundle
[17:50:13] Finished building JavaScript bundle in 60785ms.
[17:50:13] Building Android bundle
[17:51:04] Finished building JavaScript bundle in 51597ms.
[17:51:04] Analyzing assets
[17:51:06] Finished building JavaScript bundle in 1669ms.
[17:51:08] Finished building JavaScript bundle in 1526ms.
[17:51:08] Uploading assets
[17:51:08] No assets changed, skipped.
[17:51:08] Processing asset bundle patterns:
[17:51:08] - /workspace/**/*
[17:51:08] Uploading JavaScript bundles
[17:51:12] Published
[17:51:12] Your URL is

https://exp.host/@XXXX/XXXX?release-channel=test

[17:51:12] › Closing Expo server
[17:51:12] › Stopping Metro bundler
[17:51:13] Checking if this build already exists...

[17:51:13] Build started, it may take a few minutes to complete.
[17:51:13] You can check the queue length at https://expo.io/turtle-status

[17:51:13] You can make this faster. 
Get priority builds at: https://expo.io/settings/billing

[17:51:13] You can monitor the build at

 https://expo.io/dashboard/XXXX/builds/e5c32814-8613-4fef-889a-05ca982e952f

[17:51:13] Alternatively, run `expo build:status` to monitor it from the command line.

尽管开始时出现了麻烦的警告,但构建工作正常并生成了一个 .ipa 我们已成功提交试飞

[xmldom error] element parse error: Error: invalid tagName: @#[line:99,col:125]

[17:48:40] Provisioning profile is missing. It will be generated during the next build


我认为问题可能是我们正在使用的 google 云构建机器是在美国位置设置的,但上次我在我的电脑上本地使用 expo build:ios 命令时我在不同的地区。因此,仅 运行ning expo build:ios -clear-credentials 可能就足够了,您可以让 expo 创建和管理所有必需的证书。

但是我在任何地方都找不到任何信息表明在 CI(非交互式)环境中您应该使用 expo build:ios 而无需提供 apple id 和凭据