构建配置流程

了解 EAS CLI 如何为 EAS Build 配置项目。


在本指南中,你将了解当 EAS CLI 使用 eas build:configure 配置你的项目时会发生什么(或者使用 eas build,如果项目尚未配置,它会执行相同的过程)。

🌐 In this guide, you will learn what happens when EAS CLI configures your project with eas build:configure (or eas build, which runs this same process if the project is not yet configured).

配置项目时,EAS CLI 执行以下步骤:

🌐 EAS CLI performs the following steps when configuring your project:

1

询问你要配置的平台

🌐 Ask you about the platform(s) to configure

当你第一次运行该命令时,它会初始化你的 EAS 项目,并要求你选择要配置的平台。如果你只想为单个平台使用 EAS Build,也没问题。如果你改变主意,可以之后再回来配置其他平台。

🌐 When you run the command for the first time, it will initialize your EAS project and ask you to select the platform(s) you want to configure. If you only want to use EAS Build for a single platform, that's fine. If you change your mind, you can come back and configure the other later.

2

创建 eas.json

🌐 Create eas.json

该命令将在根目录下创建一个带有默认配置的 eas.json 文件。它看起来大致如下:

🌐 The command will create an eas.json file in the root directory with the default configuration. It looks something like this:

eas.json
{ "build": { "development": { "developmentClient": true, "distribution": "internal" }, "preview": { "distribution": "internal" }, "production": {} } }

如果你的项目是空的,它看起来会有点不同。

🌐 If you have a bare project, it will look a bit different.

这是你的 EAS 构建配置。它为每个平台定义了三个名为 "development""preview""production" 的构建配置文件(你可以有多个构建配置文件,如 "production""debug""testing" 等)。如果你想了解更多关于 eas.json 的信息,请参阅 使用 eas.json 配置 页面。

🌐 This is your EAS Build configuration. It defines three build profiles named "development", "preview", and "production" (you can have multiple build profiles like "production", "debug", "testing", and so on) for each platform. If you want to learn more about eas.json see the Configuration with eas.json page.

3

配置项目

🌐 Configure the project

这一步取决于你的项目类型而有所不同。

🌐 This step varies depending on the project type you have.

3.1

初始化完成

🌐 Initialization complete

这完成了项目的初始化,使其与 EAS Build 兼容。

🌐 This completes the initialization of your project to be compatible with EAS Build.

3.2

Expo 项目

🌐 Expo project

如果你还没有在 app.json 中配置 android.package 和/或 ios.bundleIdentifier,当你创建第一个构建时,EAS CLI 会提示你指定它们。

🌐 If you haven't configured your app.json with android.package and/or ios.bundleIdentifier yet, EAS CLI will prompt you to specify them when you create your first build.

  • android.package 将被用作 Android 应用的 ID,用于在 Google Play 商店中识别你的应用
  • ios.bundleIdentifier 将用于在 Apple 应用商店中识别你的应用

在上面的示例中,eas build --platform android 命令会提示设置 Android 应用 ID。如果使用 --platform ios 运行该命令,它将提示你设置 iOS 包标识符。

🌐 In the example above, the eas build --platform android command prompts to set the Android application ID. If you run the command with --platform ios, it will prompt you to set the iOS bundle identifier.

3.3

纯 React Native 项目

🌐 Bare React Native project

对于纯项目,没有额外的步骤。

🌐 There are no additional steps for bare projects.

4

下一步

🌐 Next steps

这就是将项目配置为与 EAS Build 兼容的全部内容。如果你在 eas.json 中将 cli.requireCommit 设置为 true,还有最后一步 —— 系统会提示你提交我们为你所做的所有更改。你可以选择在提交前进行审查,并且可以指定 git 提交信息,也可以使用默认信息。

🌐 That's all there is to configuring a project to be compatible with EAS Build. There is one more step, if you set cli.requireCommit to true in your eas.json — you'll be prompted to commit all the changes we made for you. You can choose to review them before committing, and you can either specify the git commit message or use a default message.