了解如何将 EAS 更新与 EAS 构建结合使用。
EAS Build 为 expo-updates
库提供了一些特殊好处。特别是,你可以在 eas.json 中配置 channel
属性,EAS Build 将在构建时在你的原生项目中更新它。
¥EAS Build includes some special benefits for expo-updates
library. In particular, you can configure the channel
property in eas.json and EAS Build will take care of updating it in your native project at build time.
本文档涵盖了将 expo-updates
库与 EAS Build 结合使用的特定问题。有关使用 EAS 更新配置磁带库的更多一般信息,请参阅 开始使用 EAS 更新。
¥This document covers concerns specific to using expo-updates
library with EAS Build. For more general information about configuring the library with EAS Update, see Getting started with EAS Update .
¥Setting the channel for a build profile
每个 建立档案 都可以分配给一个通道,因此为给定配置文件生成的版本的更新将仅提取发布到其通道的那些版本。
¥Each build profile can be assigned to a channel, so updates for builds produced for a given profile will pull only those releases that are published to its channel.
以下示例演示了如何使用 "production"
通道进行生产构建,以及如何使用 "staging"
通道进行随 内部分配 分发的测试构建。
¥The following example demonstrates how you might use the "production"
channel for production builds, and the "staging"
channel for test builds distributed with internal distribution.
{
"build": {
"production": {
"channel": "production"
},
"preview": {
"channel": "staging",
"distribution": "internal"
}
}
}
¥Binary compatibility and runtime versions
你的原生运行时可能会在每次构建时发生变化,具体取决于你是否以更改 JavaScript 的 API 协定的方式修改代码。如果你将 JavaScript 打包包发布到具有不兼容原生运行时的二进制文件(例如,JavaScript 打包包期望存在的函数不存在),那么你的应用可能无法按预期工作,或者可能崩溃。
¥Your native runtime may change on each build, depending on whether you modify the code in a way that changes the API contract with JavaScript. If you publish a JavaScript bundle to a binary with an incompatible native runtime (for example, a function that the JavaScript bundle expects to exist does not exist) then your app may not work as expected, or it may crash.
我们建议为应用的每个二进制版本使用不同的 运行时版本。任何时候更改原生运行时(在托管应用中,当你添加或删除原生库或修改 app.json 时都会发生这种情况),你应该增加运行时版本。
¥We recommend using a different runtime version for each binary version of your app. Any time you change the native runtime (in managed apps, this happens when you add or remove a native library, or modify app.json), you should increment the runtime version.
¥Previewing updates in development builds
使用 runtimeVersion
字段发布的更新无法加载到 Expo Go 中;相反,你应该使用 expo-dev-client 创建开发版本。
¥Updates published with the runtimeVersion
field can't be loaded in Expo Go; instead, you should use expo-dev-client to create a development build.
eas update
¥Environment variables and eas update
当你运行 eas update
时,构建配置文件中 env
字段上设置的环境变量不可用。了解有关使用 EAS 更新的环境变量 的更多信息。
¥Environment variables set on the env
field in build profiles are not available when you run eas update
. Learn more about using environment variables with EAS Update.