从经典更新迁移
帮助从经典更新迁移到 EAS 更新的指南。
警告 SDK 49 是最后一个支持经典更新的版本。要继续使用已弃用的
expo publish命令,请在你的应用配置中设置updates.useClassicUpdates。
EAS 更新是 Expo 更新服务的下一代。如果你正在使用经典更新,本指南将帮助你升级到 EAS 更新。
🌐 EAS Update is the next generation of Expo's updates service. If you're using Classic Updates, this guide will help you upgrade to EAS Update.
先决条件
🌐 Prerequisites
EAS 更新需要以下版本或更高版本:
🌐 EAS Update requires the following versions or greater:
- Expo SDK >= 45.0.0
- Expo CLI >= 5.3.0
- EAS CLI >= 0.50.0
- expo-updates >= 0.13.0
安装 EAS CLI
🌐 Install EAS CLI
1
安装 EAS CLI:
- npm install --global eas-cli2
然后,使用你的 Expo 账户登录:
- eas login配置你的项目
🌐 Configure your project
你需要对你的项目进行以下更改:
🌐 You'll need to make the following changes to your project:
1
使用 EAS 更新初始化你的项目:
- eas update:configure执行此命令后,你的应用配置中应该会在 expo.updates.url 和 expo.runtimeVersion 出现两个新字段。
🌐 After this command, you should have two new fields in your app config at expo.updates.url and expo.runtimeVersion.
2
为了确保更新与构建中的底层原生代码兼容,EAS Update 使用了一个名为 runtimeVersion 的新字段,它取代了项目应用配置中的 sdkVersion 字段。请从应用配置中移除 expo.sdkVersion 属性。
🌐 To ensure that updates are compatible with the underlying native code inside a build, EAS Update uses a new field named runtimeVersion that replaces the sdkVersion field in your project's app config. Remove the expo.sdkVersion property from your app config.
3
要允许更新应用于使用 EAS 构建的版本,请在 eas.json 中更新你的 EAS Build 配置文件,以包含 channel 属性。这些通道取代了 releaseChannel 属性。我们发现将 channel 命名为配置文件的名称很方便。例如,preview 配置文件有一个名为 "preview" 的 channel,而 production 配置文件有一个名为 "production" 的 channel。
🌐 To allow updates to apply to builds built with EAS, update your EAS Build profiles in eas.json to include channel properties. These channels replace releaseChannel properties. We find it convenient to name the channel after the profile's name. For instance, the preview profile has a channel named "preview" and the production profile has a channel named "production".
{ "build": { "development": { "developmentClient": true, "distribution": "internal" }, "preview": { "distribution": "internal", "channel": "preview" }, "production": { "channel": "production" } } }
4
可选:如果你的项目是一个纯 React Native 项目,请参阅 在现有项目中使用 EAS Update 了解你可能需要的额外配置。
创建新版本
🌐 Create new builds
上述更改会影响构建中的本地代码层,这意味着你需要创建新的构建才能开始发送更新。一旦构建完成,你就可以准备发布更新了。
🌐 The changes above affect the native code layer inside builds, which means you'll need to make new builds to start sending updates. Once your builds are complete, you'll be ready to publish an update.
发布更新
🌐 Publish an update
在本地对项目进行更改后,如果准备发布更新,请运行:
🌐 After making a change to your project locally, you're ready to publish an update, run:
- eas update --channel [channel-name] --message [message]# Example- eas update --channel production --message "Fixes typo"发布后,你可以在 EAS 仪表板 中查看更新。
🌐 Once published, you can see the update in the EAS dashboard.
额外的迁移步骤
🌐 Additional migration steps
- 在脚本中将
expo publish替换为eas update。你可以查看使用eas update --help发布的所有选项。 - 如果你有任何引用
expo-updates库中Updates.releaseChannel的代码,请将它们替换为Updates.channel。 - 删除任何引用
Constants.manifest的代码。它现在将始终返回null。你可以通过expo-constants库中的Constants.expoConfig访问大多数所需的属性。
了解更多
🌐 Learn more
上述步骤允许你使用类似于经典更新的流程。然而,EAS 更新更加灵活,功能更多。它可以用于创建更稳定的发布流程。了解 EAS 更新的工作原理 以及如何为你的项目和团队制定更稳定的 部署流程。
🌐 The steps described above allow you to use a similar flow to Classic Updates. However, EAS Update is more flexible and has more features. It can be used to create more stable release flows. Learn how EAS Update works and how you can craft a more stable deployment process for your project and your team.