创建你的第一个版本
了解如何使用 EAS Build 为你的应用创建构建。
EAS Build 允许你为 Google Play 商店或 Apple App Store 构建一个可以直接提交的应用二进制文件。在本指南中,让我们学习如何操作。
🌐 EAS Build allows you to build a ready-to-submit binary of your app for the Google Play Store or Apple App Store. In this guide, let's learn how to do that.
或者,如果你希望将应用直接安装到 Android 设备/模拟器或将其安装在 iOS 模拟器中,我们将向你提供解释如何执行此操作的资源。
🌐 Alternatively, if you prefer to install the app directly to your Android device/emulator or install it in the iOS Simulator, we will point you toward resources that explain how to do that.
对于一个小型应用,Android 和 iOS 平台的构建会在几分钟内触发。如果在此过程中遇到任何问题,你可以通过 Discord 和论坛寻求帮助。
先决条件
🌐 Prerequisites
EAS Build 是一项快速发展的服务。在你开始为项目创建构建之前,我们建议先查阅 限制 页面以及以下其他先决条件。
🌐 EAS Build is a rapidly evolving service. Before you set out to create a build for your project we recommend consulting the limitations page and the other prerequisites below.
一个你想要构建的 React Native 安卓和/或 iOS 项目
还没有项目?没问题。按照本指南,你可以快速轻松地创建一个“Hello world”应用。
🌐 Don't have a project yet? No problem. It's quick and easy to create a "Hello world" app that you can use with this guide.
运行以下命令以创建一个新项目:
🌐 Run the following command to create a new project:
- npx create-expo-app@latest my-app --template default@sdk-55EAS Build 也适用于由 npx create-react-native-app、npx react-native、ignite-cli 以及其他项目初始化工具创建的项目。
🌐 EAS Build also works well with projects created by npx create-react-native-app, npx react-native, ignite-cli, and other project bootstrapping tools.
Expo 用户账户
EAS Build 对任何拥有 Expo 账户的人都是可用的,无论你是否付费使用 EAS 或使用我们的免费计划。你可以在 https://expo.dev/signup 注册。
🌐 EAS Build is available to anyone with an Expo account, regardless of whether you pay for EAS or use our Free plan. You can sign up at https://expo.dev/signup.
付费订阅用户可以享受诸如额外的构建并发、优先访问以减少构建排队时间以及增加构建超时限制等质量改进。了解更多关于不同计划和福利的信息,请访问 EAS 定价。
🌐 Paid subscribers get quality improvements such as additional build concurrencies, priority access to minimize the time your builds spend queueing, and increased limits on build timeouts. Learn more about different plans and benefits at EAS pricing.
1
安装最新的 EAS CLI
🌐 Install the latest EAS CLI
EAS CLI 是一个命令行应用,你可以通过它在终端中与 EAS 服务进行交互。要安装它,请运行以下命令:
🌐 EAS CLI is the command-line app that you will use to interact with EAS services from your terminal. To install it, run the command:
- npm install -g eas-cli你也可以使用上述命令来检查是否有新的 EAS CLI 版本可用。我们鼓励你始终保持最新版本。
🌐 You can also use the above command to check if a new version of EAS CLI is available. We encourage you to always stay up to date with the latest version.
我们建议在进行全局包安装时使用
npm而不是yarn。你也可以选择使用npx eas-cli@latest。记住,每当文档中要求使用eas时,应使用它替代。
2
登录到你的 Expo 账户
🌐 Log in to your Expo account
如果你已经使用 Expo CLI 登录了 Expo 账号,可以跳过本节中描述的步骤。如果你还没有登录,请运行以下命令进行登录:
🌐 If you are already signed in to an Expo account using Expo CLI, you can skip the steps described in this section. If you are not, run the following command to log in:
- eas login你可以通过运行 eas whoami 来检查你是否已登录。
🌐 You can check whether you are logged in by running eas whoami.
3
配置项目
🌐 Configure the project
要为 EAS Build 配置 Android 或 iOS 项目,请运行以下命令:
🌐 To configure an Android or an iOS project for EAS Build, run the following command:
- eas build:configure要了解幕后发生的情况,请参阅 构建配置流程参考。
🌐 To learn more about what happens behind the scenes, see build configuration process reference.
对于开发,我们建议创建一个开发构建,这是你的应用的调试构建,并包含expo-dev-client库。它可以帮助你尽快进行迭代,并提供更灵活、可靠和完整的开发环境。要安装该库,请运行以下命令:
🌐 For development, we recommend creating a development build, which is a debug build of your app and contains the expo-dev-client library. It helps you iterate as quickly as possible and provides a more flexible, reliable, and complete development environment. To install the library, run the following command:
- npx expo install expo-dev-client某些情况下可能需要额外配置:
🌐 Additional configuration may be required for some scenarios:
- 你的应用代码是否依赖环境变量?将它们添加到你的构建配置。
- 你的项目是在单一仓库中吗?请按照这些说明操作。
- 你使用私有 npm 包吗?添加你的 npm 令牌。
- 你的应用是否依赖于特定版本的工具,例如 Node、Yarn、npm、CocoaPods 或 Xcode?在你的构建配置中指定这些版本。
4
运行构建
🌐 Run a build
为 Android 模拟器/设备或 iOS 模拟器构建
🌐 Build for Android Emulator/device or iOS Simulator
尝试 EAS Build 的最简单方式是创建一个可以在你的 Android 设备/模拟器或 iOS 模拟器上运行的构建。这比上传到应用商店更快,而且你不需要商店开发者会员账户。如果你想尝试,请阅读关于 为 Android 创建可安装的 APK 和 为 iOS 创建模拟器构建 的内容。
🌐 The easiest way to try out EAS Build is to create a build that you can run on your Android device/emulator or iOS Simulator. It's quicker than uploading it to a store, and you don't need store developer membership accounts. If you'd like to try this, read about creating an installable APK for Android and creating a simulator build for iOS.
为应用商店构建
🌐 Build for app stores
在构建应用商店的过程开始之前,你需要拥有一个商店开发者账户,并生成或提供应用签名凭证。
🌐 Before the build process can start for app stores, you will need to have a store developer account and generate or provide app signing credentials.
无论你是否有生成应用签名凭证的经验,EAS CLI 都能完成繁重的工作。你可以选择让 EAS CLI 处理应用签名凭证的整个流程。请查看以下步骤,了解更多关于 Android 应用签名凭证 或 iOS 应用签名凭证 的流程信息。
🌐 Whether you have experience with generating app signing credentials or not, EAS CLI does the heavy lifting. You can opt-in for EAS CLI to handle the app signing credentials process. Check out the steps for Android app signing credentials or iOS app signing credentials process below for more information.
需要 Google Play 开发者会员才能在 Google Play 商店分发应用。
你可以使用 EAS Build 构建并签署你的应用,但除非你拥有会员资格(一次性 25 美元费用),否则无法将其上传到 Google Play 商店。
🌐 You can build and sign your app using EAS Build, but you can't upload it to the Google Play Store unless you have a membership, a one-time $25 USD fee.
需要加入 Apple 开发者计划才能为 Apple App Store 构建应用。
如果你打算使用 EAS Build 为 Apple App Store 创建发布版,你需要一个拥有 99 美元 Apple 开发者计划 会员资格的账号。
🌐 If you are going to use EAS Build to create release builds for the Apple App Store, you need access to an account with a $99 USD Apple Developer Program membership.
在确认你拥有 Google Play 商店或 Apple App Store 账户,并决定是否让 EAS CLI 处理应用签名凭证后,你可以继续执行以下命令集以为该平台的商店构建应用:
🌐 After you have confirmed that you have a Google Play Store or Apple App Store account and decided whether or not EAS CLI should handle app signing credentials, you can proceed with the following set of commands to build for the platform's store:
- eas build --platform android- eas build --platform ios你可以通过向构建命令传递
--message来附加消息,例如,eas build --platform ios --message "Some message"。该消息将显示在网站上。当你想为团队留下构建用途的说明时,这非常方便。
或者,你可以使用 --platform all 选项同时为 Android 和 iOS 构建:
🌐 Alternatively, you can use --platform all option to build for Android and iOS at the same time:
- eas build --platform all如果你之前已经将应用发布到商店,并且希望使用现有的应用签名凭证,请按照这些说明进行配置。
Android 应用签名凭据
🌐 Android app signing credentials
- 如果你还没有为你的应用生成密钥库,你可以通过选择
Generate new keystore让 EAS CLI 为你处理,之后就完成了。密钥库会安全地存储在 EAS 服务器上。 - 如果你之前使用
expo build:android构建了你的应用,你可以在这里使用相同的凭据。 - 如果你想手动生成你的密钥库,请参阅 手动 Android 凭据指南 获取更多信息。
iOS 应用签名凭证
🌐 iOS app signing credentials
- 如果你尚未生成配置文件和/或分发证书,你可以通过登录你的苹果开发者账号并按照提示操作,让 EAS CLI 为你处理这些事务。
- 如果你已经使用
expo build:ios构建了你的应用,你可以在这里使用相同的凭据。 - 如果你想手动生成凭证,请参考手动 iOS 凭证指南获取更多信息。
5
等待构建完成
🌐 Wait for the build to complete
默认情况下,eas build 命令会等待你的构建完成,但如果你不想等待,可以中断它。在构建过程开始后,EAS CLI 会提示你访问构建详情页面,你可以通过该页面监控进度并阅读日志。你也可以通过访问 你的构建控制面板 或运行以下命令来找到该页面:
🌐 By default, the eas build command will wait for your build to complete, but you can interrupt it if you prefer not to wait. Monitor the progress and read the logs by following the link to the build details page that EAS CLI prompts once the build process gets started. You can also find this page by visiting your build dashboard or running the following command:
- eas build:list如果你是某个组织的成员,并且你的构建是代表该组织进行的,你可以在该账户的构建仪表板上查看构建详情。
🌐 If you are a member of an organization and your build is on its behalf, you will find the build details on the build dashboard for that account.
6
部署构建
🌐 Deploy the build
如果你已经达到这一步,恭喜你!根据你选择的路径,你现在要么拥有一个可以上传到应用商店的构建版本,要么拥有一个可以直接安装在安卓设备或iOS模拟器上的构建版本。
🌐 If you have made it to this step, congratulations! Depending on which path you chose, you now either have a build that is ready to upload to an app store, or you have a build that you can install directly on an Android device/iOS Simulator.
将你的应用分发到应用商店
🌐 Distribute your app to an app store
只有当你专门为此目的构建应用时,你才可以提交到应用商店。如果你为某个商店创建了构建,了解如何使用 EAS Submit 将你的应用提交到应用商店。
🌐 You will only be able to submit to an app store if you built specifically for that purpose. If you created a build for a store, learn how to submit your app to app stores with EAS Submit.
安装并运行应用
🌐 Install and run the app
只有当你明确为此目的构建应用时,才能将应用直接安装到你的 Android 设备/iOS 模拟器上。如果你是为应用商店分发而构建的,你需要先上传到应用商店,然后再从那里安装(例如,从 Apple 的 TestFlight 应用)。
🌐 You will only be able to install the app directly to your Android device/iOS Simulator if you explicitly built it for that purpose. If you built for app store distribution, you will need to upload to an app store and then install it from there (for example, from Apple's TestFlight app).
要学习如何将应用直接安装到你的 Android 设备或 iOS 模拟器,请从你的构建仪表板进入构建详情页面,然后点击“安装”按钮。
🌐 To learn how to install the app directly to your Android device/iOS Simulator, navigate to your build details page from your build dashboard and click the "Install" button.
下一步
🌐 Next steps
我们引导你完成使用 EAS Build 创建第一个构建的步骤,而没有深入介绍该过程的任何特定部分。
🌐 We walked you through the steps to create your first build with EAS Build without going into too much depth on any particular part of the process.
当你准备了解更多信息时,我们建议你继续阅读以下主题以了解更多信息:
🌐 When you are ready to learn more, we recommend proceeding through the following topics to learn more:
你可能还想深入研究参考部分,以了解有关你最感兴趣的主题的更多信息,例如:
🌐 You may also want to dig through the reference section to learn more about the topics that interest you most, such as:
- 构建 Webhook
- 构建服务器基础设施
- Android 和 iOS 构建流程的工作原理