首页指南参考教程

创建并共享内部发行版本

了解什么是内部发行版本、为什么我们需要它们以及如何创建它们。


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

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

内部分布构建

¥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

  • 使用 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:

No Android app signing credentials required for internal distribution

Android 应用签名不受限制。为开发版本生成了新的 Android 密钥库,但由于 Android 允许安装任何兼容的 .apk,因此预览版本不需要新的密钥库。

¥Android app signing is non-restrictive. A new Android Keystore was generated for development builds, but since Android allows installing any compatible .apk, there's no need for a new keystore for preview builds.

Apple 对于 iOS 设备上的应用分发有更严格的规则。我们需要一个临时配置文件,它允许明确列出允许运行应用的设备。

¥Apple has stricter rules for app distribution on iOS devices. We need an ad hoc provisioning profile, which allows explicitly listing the devices allowed to run the app.

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

    ¥To add 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.

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
Expo 中文网 - 粤ICP备13048890号