构建配置流程

了解 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

如果你尚未使用 android.package 和/或 ios.bundleIdentifier 配置你的 app.json,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 Store 上识别你的应用

    ¥android.package will be used as the Android application ID which is used to identify your app on the Google Play Store

  • ios.bundleIdentifier 将用于在 Apple App Store 上识别你的应用

    ¥ios.bundleIdentifier will be used to identify you app on the Apple App Store

在上面的例子中,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.