在云中配置开发构建
了解如何使用 EAS Build 配置项目的开发构建。
在本章中,我们将使用 EAS 为示例应用设置和配置开发构建。
¥In this chapter, we'll set up and configure a development build with EAS for our example app.

了解开发构建
¥Understanding development builds
让我们首先了解什么是开发构建以及为什么我们需要它们。
¥Let's start by learning about what are development builds and why we need them.
开发构建 是我们项目的调试版本。它针对创建应用时的快速迭代进行了优化。它包含 expo-dev-client
库,提供强大且完整的开发环境。此设置允许我们根据需要集成任何原生库或更改 原生目录 内的代码。
¥A development build is a debug version of our project. It is optimized for quick iterations when creating an app. It contains the expo-dev-client
library, which offers a robust and complete development environment. This setup allows us to integrate any native library or change code inside the native directories as required.
主要亮点
¥Key highlights
特性 | 开发构建 | Expo |
---|---|---|
开发阶段 | 为移动应用开发提供类似 Web 的迭代速度。 | 允许使用客户端应用快速迭代和测试 Expo SDK 项目。 |
合作 | 通过共享原生运行时促进团队测试。 | 通过设备上的二维码轻松共享项目。 |
第三方库支持 | 完全支持任何 第三方库,包括那些需要自定义原生代码的。 | 仅限于 Expo SDK 内的库,不适合自定义原生依赖。 |
定制化 | 使用 配置插件 进行广泛的定制并直接访问原生代码。 | 有限的定制,重点关注 Expo SDK 功能,无需直接修改原生代码。 |
有可能的使用 | 非常适合针对商店部署的成熟应用开发,提供完整的开发环境和工具。 | 非常适合学习、原型设计和实验。不建议用于生产应用。 |
1
Install expo-dev-client library
To initialize our project for a development build, let's cd
inside our project directory and run the following command to install the library:
!!!IG2!!!
Start the development server
Run the npx expo start
to start the development server:
!!!IG3!!!
This command starts the metro bundler. In the terminal window, we see the QR code followed by the Metro waiting on...
and a manifest URL:
Let's notice the changes installing the expo-dev-client
library:
- The manifest URL contains
expo-development-client
along with the app scheme - The development server now operates for a development build (instead of Expo Go).
Since we do not have a development build installed on one of our devices or an emulator/simulator, we can't run our project yet.
2
Initialize a development build
Install EAS CLI
We need to install the EAS Command Line Interface (CLI) tool as a global dependency on our local machine. Run the following command:
!!!IG4!!!
Log in or sign up for an Expo account
If you have an Expo account and are signed in using Expo CLI, skip this step. If you don't have an Expo account, sign up here and proceed with the login command described below.
To log in, run the following command:
!!!IG5!!!
This command asks for our Expo account email or username and password to complete the login.
Initialize and link the project to EAS
For any new project, the first step is to initialize and link it to the EAS servers. Run the following command:
!!!IG6!!!
On running, this command:
- Requests verification of the account owner by entering our Expo account credentials and asks if we want to create a new EAS project:
!!!IG8!!!
- Creates EAS project and provides a link to that project which we can open in the Expo dashboard:
- Generates a unique
projectId
and links this EAS project to the example app on our development machine. - Modifies app.json to include
extra.eas.projectId
and updates its value with the unique ID created.
3
Configure project for EAS Build
To set up our project for EAS Build, run the following command:
!!!IG7!!!
On running, this command:
- Prompts to select a platform: Android, iOS, or All. Since we are creating Android and iOS apps, let's select All.
- Creates eas.json in the root of our project's directory with the following configuration:
!!!IG1!!!
This is the default configuration for eas.json in a new project. It does two things:
- Defines the current EAS CLI version.
- Adds three build profiles:
development
,preview
, andproduction
.
Explore development profile further
eas.json is a collection of different build profiles. Each profile is tailored with distinct configurations to produce specific build types. These profiles can also include platform-specific settings for Android or iOS.
Currently, our focus is on the development
profile, which includes the following configuration:
developmentClient
: Enabled (true
) for creating a debug build. It loads the app using theexpo-dev-client
library, which provides development tools and generates a build artifact for device or emulator/simulator installation and allows using the app for local development as it supports updating the JavaScript on the fly.distribution
: Configured asinternal
to indicate that we want to share the build internally (instead of uploading it on app stores).
Note: Builds offer extensive customization options, including platform-specific settings and the ability to extend configurations across different build profiles. Learn more about customizing build profiles.
Summary
Chapter 1: Configure development build in cloud
We successfully used the EAS CLI to initialize, and configure our project, link it to EAS servers, and prepare a development build.
In the next chapter, let's create a development build for Android, install it on a device and an emulator, and get it running with the development server.