This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
使用 EAS 更新
了解如何将 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 Update 配置该库的一般信息,请参阅 开始使用 EAS Update。
🌐 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.
我们建议为应用的每个二进制版本使用不同的 运行时版本。每当你更改本地运行时(在使用 连续本地生成 (CNG) 的项目中,当你添加或移除本地库,或修改 app.json 时会发生这种情况),你都应该增加运行时版本号。
🌐 We recommend using a different runtime version for each binary version of your app. Any time you change the native runtime (in projects that use Continuous Native Generation (CNG), 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
在构建配置文件的 env 字段中设置的环境变量在运行 eas update 时不可用。了解有关在 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.