首页指南参考教程

内部分发

了解 EAS Build 如何为你的构建提供可与你的团队共享的 URL,以便进行内部分发。


将应用上传到 TestFlight 和 Google Play beta 可能非常耗时(例如,在可供测试人员使用之前等待构建运行通过静态分析)并且受到限制(例如,TestFlight 一次只能有一个活动构建) 。Android 和 iOS 都提供了替代机制来将应用直接分发给测试人员,因此他们可以在构建完成后立即从 Web 浏览器直接下载应用并将其安装到物理设备上。

¥Uploading your app to TestFlight and Google Play beta can be time-consuming (for example, waiting for the build to run through static analysis before becoming available to testers) and limiting (for example, TestFlight can only have one active build at a time). Both Android and iOS provide alternative mechanisms to distribute apps directly to testers, so they can download and install them to physical devices directly from a web browser as soon as the builds are completed.

EAS Build 可以帮助你解决此问题,为你的构建提供可共享的 URL,并提供有关如何运行它们的说明,这样你就可以与团队成员共享一个 URL,其中包含他们测试应用所需的所有信息。

¥EAS Build can help you with this by providing shareable URLs for your builds with instructions on how to get them running, so you can share a single URL with a teammate that'll include all of the information they need to test the app.

在 iOS 上安装应用比在 Android 上安装应用要困难一些,但这要归功于临时和企业配置文件。我们将在本文档后面详细讨论这一点。

¥Installing an app on iOS is a bit trickier than on Android, but it's possible thanks to ad hoc and enterprise provisioning profiles. We'll talk more about this later in this doc.

设置内部分发

¥Setting up internal distribution

以下步骤将指导你将内部发行版添加到 已设置为使用 EAS Build 进行构建 的项目中。总共只需要几分钟即可:

¥The following steps will guide you through adding internal distribution to a project that is already set up to build with EAS Build. It will only take a few minutes in total to:

  • 配置项目

    ¥Configure the project

  • 将几个测试 iOS 设备添加到配置文件中

    ¥Add a couple of test iOS devices to a provisioning profile

  • 开始构建 Android 和 iOS

    ¥Start builds for Android and iOS

1

配置构建配置文件

¥Configure a build profile

在你的项目中打开 eas.json。你可以使用适用于 Android 或 iOS 的预配置 preview 配置文件或 创建一个新的

¥Open eas.json in your project. You can use the pre-configured preview profile or create a new one for Android or iOS.

eas.json
{
  "build": {
    "preview": {
      "distribution": "internal"
    }
  }
}

安卓

¥Android

请注意,如果你在 Android 上覆盖 gradleCommand,则应确保它生成 .apk 而不是 .aab,以便它可以直接安装到 Android 设备。

¥Note that if you override the gradleCommand on Android, you should ensure that it produces an .apk rather than an .aab, so it is directly installable to an Android device.

iOS 系统

¥iOS

上面的配置告诉 EAS Build 你想要使用临时分发,该分发适用于所有付费 Apple 开发者账户。它不适用于免费账户。

¥The configuration above tells EAS Build that you would like to use ad hoc distribution, which is available for all paid Apple Developer accounts. It is not available for free accounts.

Do you have an Apple Developer Enterprise Program membership?

仅当你拥有具有 Apple Developer Enterprise Program 成员资格的 Apple 账户时,以下操作才有效。使用企业预配时,你可以使用 universaladhoc 预配配置文件对应用进行签名。我们推荐 universal,因为它不需要你向 Apple 注册你的设备,这是使用企业配置的主要好处。

¥The following will only work if you have an Apple account with Apple Developer Enterprise Program membership. While using Enterprise provisioning, you can sign your app using a universal or adhoc provisioning profile. We recommend universal because it does not require you to register your devices with Apple, which is the main benefit of using Enterprise provisioning.

{
  "build": {
    "preview": {
      "distribution": "internal",
      "ios": {
        "enterpriseProvisioning": "universal"
      }
    }
  }
}

2

配置应用签名

¥Configure app signing

2.1

配置 Android 的应用签名凭据

¥Configure app signing credentials for Android

Android 不限制应用的分发 - 操作系统能够安装任何兼容的 .apk 文件。因此,为内部分发配置应用签名凭据与其他类型的构建没有什么不同。在这种情况下,使用内部分发的主要好处是提供一个易于共享的 URL 来提供给测试人员下载应用。

¥Android does not restrict distribution of applications — the operating system is capable of installing any compatible .apk file. As a result, configuring app signing credentials for internal distribution is no different from other types of builds. The main benefit of using internal distribution, in this case, is to have an easily shareable URL to provide to testers for downloading the app.

2.2

配置 iOS 的应用签名凭据

¥Configure app signing credentials for iOS

Apple 限制在 iPhone 和 iPad 上分发应用,因此我们需要使用临时配置文件来构建应用,该配置文件明确列出了应用可以运行的设备。

¥Apple restricts distribution of applications on iPhones and iPads, so we will need to build the app with an ad hoc provisioning profile that explicitly lists the devices on which the application can run.

临时配置的替代方案是企业配置,它需要特殊的 Apple 开发者成员资格,每年费用为 299 美元。企业配置允许你在任何设备上运行应用,而无需进行任何类型的设备注册。

¥An alternative to ad hoc provisioning is enterprise provisioning, which requires a special Apple Developer membership that costs $299 USD per year. Enterprise provisioning allows you to run the application on any device without any sort of device registration.

设置临时配置

¥Setting up ad hoc provisioning

使用临时配置文件签名的应用可以由唯一标识符 (UDID) 在配置文件中注册的任何 iOS 设备安装。

¥Apps signed with an ad hoc provisioning profile can be installed by any iOS device whose unique identifier (UDID) is registered with the provisioning profile.

设置临时配置包括两个步骤。第一步,你将注册你希望能够安装应用的设备。运行以下命令生成可在设备上打开的 URL(以及 QR 码,为了方便起见),然后按照注册页面上的说明进行操作。

¥Setting up ad hoc provisioning consists of two steps. In the first step, you'll register devices that you want to be able to install your app. Run the following command to generate a URL (and QR code, for convenience) that you can open on your devices, and then follow the instructions on the registration page.

Terminal
# Register Apple Devices for internal distribution
eas device:create

你可以随时注册新设备,但在注册设备之前创建的版本将不会在新注册的设备上运行;只有在设备注册后创建的版本才可以安装。

¥You can register new devices at any time, but builds that were created before the device was registered will not run on newly registered devices; only builds that are created after the device is registered will be installable.

下一步是生成或更新配置文件。当你继续运行构建时,系统将引导你完成此过程。

¥The next step is to generate or update the provisioning profile. When you proceed to run a build, you will be guided through this process.

Are you setting up enterprise provisioning?

Apple 企业计划成员资格的费用为每年 299 美元和 并非所有组织都有资格,因此你可能会使用临时配置,该配置适用于任何正常的付费 Apple 开发者账户。

¥Apple Enterprise Program membership costs $299 USD per year and not all organizations will be eligible, so you will likely be using ad hoc provisioning, which works with any normal paid Apple Developer account.

如果你有 Apple 开发者企业计划成员资格 用户可以将你的应用安装到他们的设备上,而无需预先注册其 UDID;他们只需将配置文件安装到他们的设备上,然后就可以访问现有的版本。你需要在 eas build 过程中使用 Apple Developer Enterprise 账户登录才能设置正确的配置。

¥If you have an Apple Developer Enterprise Program membership users can install your app to their device without pre-registering their UDID; they just need to install the profile to their device and they can then access existing builds. You will need to sign in using your Apple Developer Enterprise account during the eas build process to set up the correct provisioning.

如果你通过企业配置和 App Store 分发应用,则需要为每个上下文都有一个不同的打包包标识符。我们推荐:

¥If you distribute your app both through enterprise provisioning and the App Store, you will need to have a distinct bundle identifier for each context. We recommend either:

  • 在托管项目中,使用 app.config.js 动态切换标识符。

    ¥In managed projects, use app.config.js to dynamically switch identifiers.

  • 在裸项目中,为每个包标识符创建单独的 scheme,并在单独的构建配置文件中指定方案名称。

    ¥In bare projects, create a separate scheme for each bundle identifier and specify the scheme name in separate build profiles.

Are you using manual local credentials?

如果是这样,请确保将你的 credentials.json 指向你通过 Apple 开发者门户生成的临时或企业配置文件(更新用于另一种类型的分发的现有 credentials.json,或者将其替换为指向 到适当的配置文件)。请注意,EAS CLI 仅对你的本地凭据进行有限的验证,你必须手动处理设备 UDID 注册。了解有关 使用本地凭据 的更多信息。

¥If so, make sure to point your credentials.json to an ad hoc or enterprise provisioning profile that you generate through the Apple Developer Portal (either update an existing credentials.json used for another type of distribution or replace it with a new one that points to the appropriate provisioning profile). Beware that EAS CLI does only a limited validation of your local credentials, and you will have to handle device UDID registration manually. Read more about using local credentials.

3

使用内部构建配置文件运行构建

¥Run a build with the internal build profile

现在我们已经设置了构建配置文件和应用签名,运行内部分发的构建就像任何其他构建一样。

¥Now that we have set up our build profile and app signing, running a build for internal distribution is just like any other build.

Terminal
# Create Android and iOS builds for internal distribution
eas build --profile preview --platform all

如果你使用临时配置但尚未注册任何设备,系统会要求你立即注册它们(或退出当前命令并再次运行 eas device:create)。构建命令将等待新设备注册。扫描终端中显示的二维码,然后按照该页面上的说明注册你的设备。完成后,返回终端并继续。

¥If you're using ad hoc provisioning but you haven't registered any devices yet, you'll be asked to register them now (or exit the current command and run eas device:create again). The build command will wait for the new device to register. Scan the QR code that is presented in the terminal and follow the instructions on that page to register your device. When you're done, return to the terminal and continue.

构建完成后,你将获得一个 URL,你可以与团队共享该 URL 以下载并安装该应用。

¥When the build completes, you will be given a URL that you can share with your team to download and install the app.

4

安装并运行构建

¥Install and run the build

按构建页面上的 "安装" 按钮,然后按照模式中显示的说明进行操作。

¥Press the "Install" button on the build page and follow the instructions presented in the modal.

如果你运行的是 iOS 16 或更高版本并且尚未打开开发者模式,则需要 启用它 才能运行构建。如果你使用的是企业配置,则这不适用。

¥If you're running iOS 16 or above and haven't yet turned on Developer Mode, you will need to enable it before you can run your build. This doesn't apply if you're using enterprise provisioning.

5

CI 自动化(可选)

¥Automation on CI (optional)

可以使用 --non-interactive 标志在 CI 中以非交互方式运行内部分发版本;但是,如果你在 iOS 上使用临时配置,则在使用此标志时将无法将新设备添加到你的配置配置文件中。通过 eas device:create 注册设备后,你需要交互运行 eas build 并向 Apple 进行身份验证以进行 EAS,以将设备添加到你的配置文件中。了解有关从 CI 触发构建的更多信息

¥It's possible to run internal distribution builds non-interactively in CI using the --non-interactive flag; however, if you are using ad hoc provisioning on iOS you will not be able to add new devices to your provisioning profile when using this flag. After registering a device through eas device:create, you need to run eas build interactively and authenticate with Apple for EAS to add the device to your provisioning profile. Learn more about triggering builds from CI.

管理设备

¥Managing devices

你可以通过运行以下命令查看通过 eas device:create 注册的任何设备:

¥You can see any devices registered via eas device:create by running:

Terminal
# List devices registered for ad hoc provisioning
eas device:list

在 Expo 中注册用于临时配置的设备在用于通过 EAS Build 生成新的内部构建或通过 eas build:resign 生成 放弃现有的构建 的配置文件后,将出现在你的 Apple 开发者门户上。

¥Devices registered with Expo for ad hoc provisioning will appear on your Apple Developer Portal after they are used to generate a provisioning profile for a new internal build with EAS Build or to resign an existing build with eas build:resign.

删除设备

¥Remove devices

如果不再使用某个设备,可以通过运行以下命令将其从该列表中删除:

¥If a device is no longer in use, it can be removed from this list by running:

Terminal
# Delete devices from your Expo account, optionally disable them on the Apple Developer Portal
eas device:delete

此命令还会提示你在 Apple 开发者门户上禁用该设备。对于每个应用的临时分发,已禁用的设备仍计入 Apple 的设备数量限制为 100 台

¥This command will also prompt you to disable the device on the Apple Developer Portal. Disabled devices still count against Apple's limit of 100 devices for ad hoc distribution per app.

重命名设备

¥Rename devices

通过网站 URL/QR 代码添加的设备在选择 EAS 构建时将默认显示其 UDID。你可以使用以下命令为设备分配友好名称:

¥Devices added via the website URL/QR code will default to displaying their UDID when selecting them for an EAS Build. You can assign friendly names to your devices with the following command:

Terminal
# Rename devices on Expo and the Apple Developer Portal
eas device:rename
Expo 中文网 - 粤ICP备13048890号