EAS 构建
EAS Build 是一项托管服务,用于为你的 Expo 和 React Native 项目构建应用二进制文件。
EAS Build 是一个托管的 Expo 应用服务 (EAS) 服务,它可以为你的 Expo 和 React Native 项目构建应用二进制文件(也称为独立应用)。
EAS Build 通过提供适用于 Expo 和 React Native 项目的默认配置,使构建可分发应用变得简单且易于自动化,并可为你处理应用的签名凭证(如果你愿意)。它还通过内部分发(使用临时和/或企业“通用”配置)使与团队共享构建比以往任何时候都更容易,深度集成 EAS Submit 用于应用商店提交,并对expo-updates库提供一流支持。
🌐 EAS Build makes building your apps for distribution simple and easy to automate by providing defaults that work well for Expo and React Native projects out of the box, and by handling your app signing credentials for you (if you wish). It also makes sharing builds with your team easier than ever with internal distribution (using ad hoc and/or enterprise "universal" provisioning), deeply integrates with EAS Submit for app store submissions, and has first-class support for the expo-updates library.
EAS Build 也被设计为适用于任何原生项目,无论你是否使用 Expo 和 React Native。它是从 npx create-expo-app 或 npx @react-native-community/cli@latest init 快速发布到应用商店的最快方式。
🌐 EAS Build is also designed to work for any native project, whether or not you use Expo and React Native. It's the fastest way to get from npx create-expo-app or npx @react-native-community/cli@latest init to app stores.
快速开始
🌐 Quick start
信息 以下
eas命令需要 EAS CLI。有关更多信息,请参阅 如何安装 EAS CLI。
要构建你的应用,请运行以下命令:
🌐 To build your app, run the following command:
- eas build --platform all此命令将你的项目发送到 EAS Build,并生成可安装的 Android 和 iOS 二进制文件。你也可以通过传入 --platform android 或 --platform ios 来一次只构建一个平台。有关完整的设置说明,请参阅 创建你的第一个构建。
🌐 This command sends your project to EAS Build and produces installable binaries for Android and iOS. You can also build for one platform at a time by passing in --platform android or --platform ios as desired. For complete setup instructions, see Create your first build.
主要特点
🌐 Key features
- 针对 Android 和 iOS 的云构建,环境一致
- 自动配置和管理应用签名凭证,或使用你自己的凭证
- 通过 URL 分享内部分发版本
- 在 eas.json 中使用 构建配置(命名的构建设置集合)以及与 EAS 工作流 或 CI 流水线 的集成来自动化构建
- 通过
--auto-submit和 EAS Submit 自动提交成功的构建到应用商店 - 一流的
expo-updates集成,支持每个配置文件的通道和运行时版本指导 - 在团队中重复使用 开发构建。当两名团队成员运行
eas build:dev且项目指纹匹配时,将从 EAS 下载现有构建,而不是创建新的构建 - 通过依赖缓存和自定义缓存路径加快构建速度
- 使用 Expo Orbit 在设备上安装构建和更新
何时使用 EAS Build
🌐 When to use EAS Build
| 情景 | 建议 |
|---|---|
| 为应用商店构建生产就绪的二进制文件 | |
| 通过 内部分发 与测试人员共享构建版本 | |
| 在无需本地环境设置的情况下,团队成员之间保持构建一致 | |
| 通过 CI 或 EAS 工作流程 自动化构建 | |
| 托管的应用签名凭据 | |
| 本地调试原生代码 |
常见问题
🌐 Frequently asked questions
在提交到应用商店之前,我如何与团队分享构建版本?
使用内部分发通过URL共享构建。在eas.json的构建配置文件中设置"distribution": "internal",以生成适用于Android的可安装Android包(APK)文件,或用于iOS的临时构建。
🌐 Use internal distribution to share builds with a URL. Set "distribution": "internal" in your build profile in eas.json to generate installable Android Package (APK) files for Android or ad hoc builds for iOS.
我可以在现有的 React Native 项目中使用 EAS Build 吗?
是的。EAS Build 可以与使用 npx react-native init 或类似工具创建的现有 React Native 项目一起使用。有关更多信息,请参见 使用 Expo 与现有 React Native 应用的概述。
🌐 Yes. EAS Build works with existing React Native projects created with npx react-native init or similar tools. See Overview of using Expo with existing React Native apps for more information.
EAS Build 会处理应用签名证书吗?
是的。EAS Build 可以生成和管理 Android 密钥库、iOS 配置描述文件 和 分发证书,或者使用你提供的凭据。有关更多信息,请参阅 应用签名凭据。
🌐 Yes. EAS Build can generate and manage Android keystores, iOS provisioning profiles and distribution certificates, or use credentials you provide. See App signing credentials for more information.
我可以在本地运行构建,而不是在云端吗?
是的。使用 本地构建 和 eas build --local 在你的机器上运行构建。这对于调试或需要本地构建的安全策略很有用。
🌐 Yes. Use local builds with eas build --local to run builds on your machine. This is useful for debugging or for security policies that require local builds.
我可以在 EAS Workflows 或 CI 流水线中使用 EAS Build 吗?
是的。EAS Build 使用 build 作业类型与 EAS Workflows 集成。在你的工作流配置中添加一个构建作业,例如:
🌐 Yes. EAS Build integrates with EAS Workflows using the build job type. Add a build job to your workflow configuration, for example:
jobs: build_ios: type: build params: platform: ios
构建任务支持对两个平台进行构建,或根据分支进行条件构建:
🌐 The build job supports builds for both platforms or conditional builds based on the branch:
jobs: build: type: build params: platform: all profile: ${{ github.ref_name == 'main' && 'production' || 'preview' }}
有关更多信息和其他使用示例,请参见 EAS 工作流构建作业。
🌐 For more information and other usage examples, see the EAS Workflows build job.
EAS Build 支持使用 GitHub 构建 和 在 CI 上构建,兼容任何提供商。
🌐 EAS Build supports builds from GitHub and building on CI with any provider.
EAS Build 使用什么构建服务器基础设施?
Android 构建在托管于 Google 云平台的 Linux 运行器上运行,iOS 构建在托管于 Expo macOS 云的 macOS 运行器上运行。请参阅 构建服务器基础设施。
🌐 Android builds run on Linux runners hosted in Google Cloud Platform, and iOS builds run on macOS runners hosted in Expo's macOS cloud. See Build server infrastructure.
开始使用
🌐 Get started
在 iOS 和/或 Android 上设置并运行应该只需几分钟的时间。
EAS Build 可以通过一个链接帮助分享你应用的预览版本。
了解 EAS Build 如何将你成功的构建自动上传到应用商店。
自动升级版本号,让你再也不用为此操心。
EAS Build 是一个托管服务,也可以在你自己的机器上运行,例如,用于调试或遵守公司安全政策。
EAS Build 是一个新的且快速发展的工具,因此我们建议先熟悉当前的限制。