创建并共享内部发行版本

了解内部分发构建、我们为什么需要它们以及如何创建它们。


在本章中,我们将学习如何设置 内部分布构建

¥In this chapter, we'll learn how to set up internal distribution builds.

Watch: How to create and share an internal distribution build
Watch: How to create and share an internal distribution build

内部分布构建

¥Internal distribution build

内部分发版本非常适合与团队成员共享更新,允许技术和非技术利益相关者直接提供反馈。与开发版本不同,这些版本不需要运行开发服务器,从而简化了测试过程。

¥Internal distribution builds are ideal for sharing updates with team members, allowing both technical and non-technical stakeholders to provide feedback directly. Unlike development builds, these do not require running a development server, simplifying the testing process.

内部分发应用的方法

¥Ways to distribute an app internally

Google 和 Apple 都提供了内部共享应用的内置机制:

¥Both Google and Apple provide built-in mechanisms for sharing apps internally:

  • 安卓:使用 Google Play 测试版

    ¥Android: Using Google Play beta

  • iOS:使用测试飞行

    ¥iOS: Using TestFlight

然而,这两种传统方法都有其局限性。例如,TestFlight 限制一次只能进行一个活动构建。

¥However, both of these traditional methods have their limitations. For example, TestFlight limits to one active build at a time.

EAS Build 加快分发速度

¥EAS Build for faster distribution

EAS Build 加快了这一过程。它为我们的构建创建可共享的链接,并提供使用它们的说明。它有一个默认配置,旨在促进内部分发,为传统方法提供更有效的替代方案。

¥EAS Build speeds up the process. It creates shareable links for our builds and provides instructions on using them. It has a default configuration designed to facilitate internal distribution, offering a more efficient alternative to traditional methods.

创建内部分发版本

¥Create an internal distribution build

要使用 EAS Build 创建和分发构建,我们需要执行以下步骤:

¥To create and distribute a build with EAS Build, we need to follow these steps:

1

配置预览构建配置文件

¥Configure preview build profile

从 eas.json 中的初始设置开始,我们已经有了一个默认配置,其中包括专为内部分发而设计的 preview 构建配置文件:

¥From our initial setup in eas.json, we already have a default configuration that includes a preview build profile designed for internal distribution:

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

这就是我们创建第一个内部发行版本所需的全部内容。上述代码片段中的 preview 构建配置文件具有 distribution 属性,其值设置为 internal。此值允许我们与任何人共享我们的构建 URL,以便他们可以将其安装在他们的设备上,并且不需要开发服务器来运行应用。

¥This is all we need to create our first internal distribution build. The preview build profile from the above snippet has a distribution property whose value is set to internal. This value allows us to share our build URLs with anyone so they can install it on their device and do not require a development server to run the app.

正如前面章节中所讨论的,对于非应用商店构建,Android 需要 .apk,iOS 需要 .ipa 格式。这也适用于内部发行版本。当 distribution 设置为 internal 时,会自动以这些文件格式为设备创建应用二进制文件。

¥As discussed in the previous chapters, for non-app store builds, Android requires .apk and iOS needs .ipa formats. This applies to internal distribution builds as well. The distribution when set to internal, automatically creates the app binary in these file formats for devices.

2

创造

¥Create

创建内部分发版本需要 应用签名凭据

¥Creating an internal distribution build requires app signing credentials.

Android 应用签名不受限制,允许安装任何兼容的 .apk 文件。当创建开发构建时,会为其生成一个新的 Android Keystore。因此,无需为预览版本生成新的密钥库。

¥Android app signing is non-restrictive and allows installing any compatible .apk file. When a development build was created, a new Android Keystore was generated for it. Hence, there is no need to generate a new keystore for preview builds.

另一方面,Apple 对 iOS 设备上的应用分发有更严格的规定。我们需要一个临时配置文件,明确列出允许运行应用的设备。一些应用满足特定要求的组织可能能够使用 Apple 开发者企业计划 在内部向更大的受众分发应用。

¥On the other hand, Apple has stricter rules for app distribution on iOS devices. We need an ad hoc provisioning profile that explicitly lists the devices allowed to run the app. Some organizations whose apps meet specific requirements may be able to use the Apple Developer Enterprise Program to distribute apps internally to a larger audience.

  • 使用 preview 配置文件启动 Android 构建:

    ¥Use the preview profile to initiate an Android build:

Terminal
eas build --platform android --profile preview
  • 该命令会触发 EAS Build,在 Expo 仪表板上,我们可以看到构建的进度:

    ¥This command triggers the EAS Build, and on the Expo dashboard, we can see the build's progress:

使用临时配置文件签名的应用可由已在配置文件中注册 UDID 的 iOS 设备安装。

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

  • 要注册更多设备,请使用 eas device:create。此命令注册 iOS 设备,并向我们提供 URL 或 QR 代码以共享设备注册:

    ¥To register more devices, use eas device:create. This command registers an iOS device and gives us a URL or QR code to share for device registration:

Terminal
eas device:create
  • 此命令注册 iOS 设备以安装应用,生成用于设备注册的可共享 URL(或 QR 代码)。

    ¥This command registers an iOS device for app installation, generating a shareable URL (or QR code) for device registration.

    提示:该命令可以随时启用设备注册。但是,只有注册后创建的版本才能在新添加的设备上运行。
  • 要创建预览版本,我们需要使用 preview 配置文件和 eas build 命令:

    ¥To create the preview build, we need to use the preview profile with the eas build command:

Terminal
eas build --platform ios --profile preview
  • 该命令会触发 EAS Build,在 Expo 仪表板上,我们可以看到构建的进度:

    ¥This command triggers the EAS Build, and on the Expo dashboard, we can see the build's progress:

Alternative method to register devices using eas build:resign

eas build:resign 命令可用于使用新的临时配置文件对现有 iOS .ipa 进行重新签名,从而无需完全重建。

¥eas build:resign command can be used to re-sign an existing iOS .ipa with a new ad hoc provisioning profile, eliminating the need for a full rebuild.

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:

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

安装

¥Install

构建完成后,构建工件部分会更新,表明构建已完成。本节提供了可用于在 iOS 设备上运行开发版本的方法:Expo 轨道和安装按钮。

¥Once the build finishes, the Build artifact section gets updated, indicating that the build is complete. This section provides the methods available for running the development build on an iOS device: Expo Orbit and Install button.

  • 打开构建的详细信息页面。如果你与其他人共享构建,你可以向他们发送构建的链接。他们将能够打开构建的详细信息页面或构建工件详细信息,其中包括 Expo Orbit。

    ¥Open the build's detail page. If you are sharing the build with someone else, you can send them the link to the build. They'll be able to open the build's detail page or build artifact details which include Expo Orbit.

  • 使用 USB 将 Android 或 iOS 设备连接到我们的机器。

    ¥Connect the Android or iOS device to our machine using USB.

  • 打开 Orbit 菜单栏应用。

    ¥Open the Orbit menu bar app.

  • 在 Orbit 应用中选择设备。

    ¥Select the Device in the Orbit app.

  • 在“构建工件”下,单击“使用 Orbit 打开”。

    ¥Under Build artifact, click the Open with Orbit.

Alternate: Use Install and QR code
  • 打开构建的详细信息页面。如果你与其他人共享构建,你可以向他们发送构建页面的链接。他们将能够打开它并查看构建工件的详细信息,其中包括 Expo 轨道。

    ¥Open the build's detail page. If you are sharing the build with someone else, you can send them the link to the build page. They'll be able to open it and see build artifact details which includes Expo Orbit.

  • 单击“构建工件”部分下的“安装”以显示“在测试设备上安装”弹出窗口。

    ¥Click Install under the Build artifact section to display the Install on a test device popup.

  • 复制将链接发送到设备部分中的链接并将其发送到测试设备。

    ¥Copy the link from Send a link to a device section and send it to the test device.

4

运行

¥Run

点击设备上的应用图标即可开始预览版本。不需要开发服务器。

¥Tap the app icon on your device to start the preview build. There is no need for a development server.

由于我们已经设置了多个应用变体,因此我们可以看到开发变体和预览变体分别安装在我们的设备上。例如:

¥Since we have already set up multiple app variants, we can see both the development and preview variants installed separately on our devices. For example:

  • 在安卓上:

    ¥On Android:

  • 在 iOS 上:

    ¥On iOS:

概括

¥Summary

Chapter 6: Create and share internal distribution build

We successfully created internal distribution builds for Android and iOS, used ad hoc provisioning for iOS, and installed multiple app variants on the same device.

In the next chapter, learn about developer-facing and user-facing app versions and how to manage them automatically.

Next: Manage different app versions