了解如何使用 expo-dev-client 库在开发版本中预览已发布的 EAS 更新。
expo-dev-client
库允许通过创建开发构建来启动项目的不同版本。任何兼容的 EAS 更新都可以在开发版本中预览。
¥expo-dev-client
library allows launching different versions of a project by creating a development build. Any compatible EAS Update can be previewed in a development build.
本指南介绍了使用扩展选项卡或构建特定更新 URL 在开发版本中加载和预览已发布更新所需的步骤。
¥This guide walks through the steps required to load and preview a published update inside a development build using the Extensions tab or constructing a specific Update URL.
¥Prerequisites
你的设备或 Android 模拟器或 iOS 模拟器上的 创建开发版本并安装它。
¥Create a development build and install it on your device or Android Emulator or iOS Simulator.
确保你的开发版本具有 已安装 expo-updates
库。
¥Make sure your development build has the expo-updates
library installed.
¥What is an Extensions tab
当在开发版本中使用 expo-updates
库时,“扩展”选项卡提供自动加载和预览已发布更新的功能。
¥When using the expo-updates
library inside a development build, the Extensions tab provides the ability to load and preview a published update automatically.
¥Preview an update using the Extensions tab
1
在你的项目中本地进行非原生更改,然后进行 发布它们使用 eas update
。更新将发布在分支上。
¥Make non-native changes locally in your project and then publish them using eas update
. The update will be published on a branch.
2
发布更新后,打开开发版本,转到“扩展”,然后点击“登录”以在开发版本中登录 Expo 账户。此步骤是“扩展”选项卡加载与你的 Expo 账户下的项目相关的任何已发布更新所必需的。
¥After publishing the update, open your development build, go to Extensions, and tap Login to log in to your Expo account within the development build. This step is required for the Extensions tab to load any published updates associated with the project under your Expo account.
3
登录后,“扩展”选项卡内将显示“EAS 更新”部分,其中包含一个或多个最新发布的更新。点击你要上一个更新旁边的“打开”。
¥After logging in, an EAS Update section will appear inside the Extensions tab with one or more of the latest published updates. Tap Open next to the update you want to previous.
在扩展选项卡中,你可以查看分支的所有已发布更新的列表。点击“扩展”选项卡中的分支名称。
¥In the Extensions tab, you can view the list of all published updates for a branch. Tap the branch name in the Extensions tab.
¥Preview an update using the Expo dashboard
你还可以按照以下步骤使用 Expo 仪表板预览更新:
¥You can also preview an update using the Expo dashboard by following the steps below:
运行命令发布更新后,单击 CLI 中的已发布更新链接。这将在 Expo 仪表板的更新页面上打开更新的详细信息。
¥Click the published updated link in the CLI after running the command to publish an update. This will open the update's details on the Updates page in the Expo dashboard.
单击预览。这将打开预览对话框。
¥Click Preview. This will open the Preview dialog.
要预览更新,你可以使用设备的相机扫描二维码,也可以选择 在 Open with Orbit 下启动更新 平台。
¥To preview the update, you can either scan the QR code with your device's camera or select a platform to launch the update under Open with Orbit.
¥Construct an update URL
作为前几节中描述的方法的替代方案,你可以构建一个特定的 URL 以在开发版本中打开你的 EAS 更新。URL 将如下所示:
¥As an alternative to the methods described in the previous sections, you can construct a specific URL to open your EAS Update in the development build. The URL will look like the following:
[slug]://expo-development-client/?url=[https://u.expo.dev/project-id]/group/[group-id]
# Example
my-app://expo-development-client/?url=https://u.expo.dev/675cb1f0-fa3c-11e8-ac99-6374d9643cb2/group/47839bf2-9e01-467b-9378-4a978604ab11
让我们分解此 URL 以了解每个部分的作用:
¥Let's break this URL to understand what each part does:
URL 的一部分 | 描述 |
---|---|
slug | 在应用配置中找到项目的 slug。 |
://expo-development-client/ | 深层链接与 expo-dev-client 库一起使用所必需的。 |
?url= | 定义 url 查询参数。 |
https://u.expo.dev/675cb1f0-fa3c-11e8-ac99-6374d9643cb2 | 这是更新 URL,位于 updates.url 下的项目应用配置内。 |
/group/47839bf2-9e01-467b-9378-4a978604ab11 | 更新的组 ID。 |
构建 URL 后,将其直接复制并粘贴到手动输入 URL 下的开发构建启动器屏幕中。
¥Once you've constructed the URL, copy and paste it directly into the development build's launcher screen under Enter URL Manually.
或者,你可以使用设备的相机 为 URL 创建二维码 并进行扫描。扫描后,URL 将打开指定通道的开发版本。
¥Alternatively, you can create a QR code for the URL and scan it using your device's camera. When scanned, the URL will open up the development build to the specified channel.
¥Example
See a working example of using expo-dev-client
with EAS Update.