了解如何使用 EAS Build 为你的应用创建构建。
EAS Build 允许你为 Google Play Store 或 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 and Forums 联系。
¥For a small app, builds for Android and iOS platforms trigger within a few minutes. If you encounter any issues along the way, you can reach out on Discord and Forums.
¥Prerequisites
EAS Build 是一项快速发展的服务。在你开始为你的项目创建构建之前,我们建议你查阅 limitations 页面和下面的其他先决条件。
¥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.
还没有项目吗?没问题。通过本指南可以快速轻松地创建 "你好世界" 应用。
¥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 my-app
EAS 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.
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.
付费订阅者可以获得质量改进,例如额外的构建并发性、优先访问以最大限度地减少构建花费的排队时间,以及增加构建超时的限制。在 电子防盗系统定价 了解有关不同计划和福利的更多信息。
¥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
¥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
。¥We recommend using
npm
instead ofyarn
for global package installations. You may alternatively usenpx eas-cli@latest
. Remember to use that instead ofeas
whenever it's called for in the documentation.
2
¥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.
某些场景可能需要额外配置:
¥Additional configuration may be required for some scenarios:
你的应用代码依赖于环境变量吗?将它们添加到你的构建配置中。
¥Does your app code depend on environment variables? Add them to your build configuration.
你的项目位于 monorepo 内吗?请遵循这些说明。
¥Is your project inside of a monorepo? Follow these instructions.
你使用私有 npm 包吗?添加你的 npm 令牌。
¥Do you use private npm packages? Add your npm token.
你的应用是否依赖于 Node、Yarn、npm、CocoaPods 或 Xcode 等特定版本的工具?在构建配置中指定这些版本。
¥Does your app depend on specific versions of tools like Node, Yarn, npm, CocoaPods, or Xcode? Specify these versions in your build configuration.
4
¥Run a build
¥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.
你可以使用 EAS Build 构建并签署你的应用,但无法将其上传到 Google Play 商店,除非你拥有成员资格(一次性费用为 25 美元)。
¥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.
如果你要使用 EAS Build 为 Apple App Store 创建发布版本,则需要访问具有 99 美元 苹果开发者计划 成员资格的账户。
¥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"
)来将消息附加到构建。该消息将出现在网站上。当你想为你的团队留下关于构建目的的注释时,它会派上用场。¥You can attach a message to the build by passing
--message
to the build command, for example,eas build --platform ios --message "Some message"
. The message will appear on the website. It comes in handy when you want to leave a note with the purpose of the build for your team.
或者,你可以使用 --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
如果你之前已将应用发布到商店并拥有想要使用的现有 应用签名凭据,则 请按照以下说明进行配置。
¥If you have released your app to stores previously and have existing app signing credentials that you want to use, follow these instructions to configure them.
¥Android app signing credentials
如果你尚未为你的应用生成密钥库,你可以通过选择 Generate new keystore
让 EAS CLI 为你处理,然后就完成了。密钥库安全地存储在 EAS 服务器上。
¥If you have not yet generated a keystore for your app, you can let EAS CLI take care of that for you by selecting Generate new keystore
, and then you are done. The keystore is stored securely on EAS servers.
如果你之前使用 expo build:android
构建过应用,则可以在此处使用相同的凭据。
¥If you have previously built your app with expo build:android
, you can use the same credentials here.
如果你想手动生成密钥库,请参阅 手动 Android 凭证指南 了解更多信息。
¥If you want to manually generate your keystore, please see the manual Android credentials guide for more information.
¥iOS app signing credentials
如果你尚未生成配置文件和/或分发证书,你可以通过登录你的 Apple 开发者计划账户并按照提示操作,让 EAS CLI 为你处理这些事情。
¥If you have not generated a provisioning profile and/or distribution certificate yet, you can let EAS CLI take care of that for you by signing into your Apple Developer Program account and following the prompts.
如果你已经使用 expo build:ios
构建了应用,则可以在此处使用相同的凭据。
¥If you have already built your app with expo build:ios
, you can use the same credentials here.
如果你想手动生成凭据,请参阅 手动 iOS 凭据指南 了解更多信息。
¥If you want to rather manually generate your credentials, refer to the manual iOS credentials guide for more information.
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.
你的构建失败了吗?请仔细检查你是否遵循了 配置步骤 中的任何适用说明,并在需要时参阅 故障排除指南。
¥Did your build fail? Double check that you followed any applicable instructions in the configuration step and refer to the troubleshooting guide if needed.
6
¥Deploy the build
如果你已完成这一步,那么恭喜你!根据你选择的路径,你现在要么拥有一个可以上传到应用商店的构建,要么拥有一个可以直接安装在 Android 设备/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 Start Building section of this documentation to learn about topics such as:
你可能还想深入研究参考部分,以了解有关你最感兴趣的主题的更多信息,例如:
¥You may also want to dig through the reference section to learn more about the topics that interest you most, such as: