创建并共享内部发行版本
了解内部分发构建、我们为什么需要它们以及如何创建它们。
在本章中,我们将学习如何设置内部分发构建。
🌐 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 测试版
- iOS:使用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:
{ "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 密钥库。因此,预览版本无需生成新的密钥库。
🌐 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.
另一方面,苹果对在 iOS 设备上分发应用有更严格的规定。我们需要一个明确列出允许运行该应用的设备的临时配置文件。一些符合特定要求的组织,可能能够使用 Apple Developer Enterprise Program 在内部将应用分发给更大的受众。
🌐 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 构建:
- eas build --platform android --profile preview- 此命令会触发 EAS 构建,在 EAS 仪表板上,我们可以看到构建的进度:
使用临时配置文件签名的应用可以被其 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 或二维码:
- eas device:create-
此命令用于注册 iOS 设备以安装应用,并生成可分享的设备注册 URL(或二维码)。
信息 提示:此命令可随时启用设备注册。但只有在注册后创建的构建才能在新添加的设备上运行。
-
要创建预览版本,我们需要使用
preview配置文件和eas build命令:
- eas build --platform ios --profile preview- 此命令会触发 EAS 构建,在 EAS 仪表板上,我们可以看到构建的进度:
使用 eas build:resign注册设备的替代方法
eas build:resign 命令可用于使用新的临时授权配置文件重新签署现有的 iOS .ipa,无需完全重新构建。
你正在设置企业配置吗?
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 企业开发者账户登录,以设置正确的配置。
🌐 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:
- 在使用 Expo CLI 生成的项目中,使用 app.config.js 动态切换标识符。
- 在现有的 React Native 项目中,为每个 bundle 标识符创建一个单独的
scheme,并在不同的构建配置中指定方案名称。
你在使用手动本地凭据吗?
如果是这样,请确保将你的 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 Orbit 和安装按钮。
🌐 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 的构建产物详情。
- 使用 USB 将 Android 或 iOS 设备连接到你的电脑。
- 打开 Orbit 菜单栏应用。
- 在 Orbit 应用中选择 设备。
- 在构建生成物下,点击用 Orbit 打开。
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:
- 在安卓上:
- 在 iOS 上:
概括
🌐 Summary
Chapter 6: Create and share internal distribution build
我们成功创建了用于 Android 和 iOS 的内部分发版本,iOS 使用了临时配置,并在同一设备上安装了多个应用变体。
在下一章中,了解面向开发者和面向用户的应用版本以及如何自动管理它们。