This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

开发构建简介

了解如何在你的 Expo 项目中创建一个开发版本,以及为什么要使用开发版本而不是 Expo Go。


创建一个带有 AI 代理的开发版

把这个粘贴到 Claude、Cursor、Codex 或其他代理里。

当你使用 create-expo-app 创建一个新的 Expo 应用时,你会从一个项目开始,在本地机器上更新 TypeScript/JavaScript 代码,并在 Expo Go 应用中查看更改。开发构建本质上是你自己的 Expo Go 版本,你可以自由使用任何原生库并更改任何原生配置。

🌐 When you create a new Expo app with create-expo-app, you start with a project where you update TypeScript/JavaScript code on your local machine and view the changes in the Expo Go app. A development build is essentially your own version of Expo Go where you are free to use any native libraries and change any native configuration.

当你想创建自己的应用并发布到应用商店时,推荐使用开发版构建。它包含 expo-dev-client 库,这个库增强了内置的 React Native 开发工具。这个工具还支持检查网络请求,还有一个 “启动器”界面,让你可以在不同的开发服务器之间切换(比如在你电脑上运行的服务器或队友电脑上的服务器),以及切换应用的不同部署版本(比如通过 EAS Update 发布的更新)。

🌐 A development build is recommended when you want to create your own app and release to app stores. It includes the expo-dev-client library, which augments the built-in React Native development tooling. The tooling also includes support for inspecting network requests and a "launcher" UI that lets you switch between different development servers (such as between a server running on your machine or a teammate's machine) and deployments of your app (such as published updates with EAS Update).

Expo Go 与开发构建:你应该使用哪一个?
Expo Go 与开发构建:你应该使用哪一个?

在这个教程视频中,Beto 解释了每一个是什么以及什么时候选择开发版。

你想怎么构建你的开发版本?

🌐 How would you like to build your development build?

这三种方法生成的开发版本都是一样的,它们的区别在于应用在哪儿编译,以及你的电脑上需要安装什么。

🌐 All three methods produce the same development build. They differ in where the app compiles and what you need to have installed on your machine.


本地构建

🌐 Build locally

用 Expo CLI 和你本地的工具链自己编译应用。无需 Expo 账户,这是在没有付费 Apple 开发者账户的情况下在 iPhone 上安装开发版本的唯一方法。

🌐 Compile the app yourself with Expo CLI and your native toolchain. No Expo account is required and this is the only way to install a development build on an iPhone without a paid Apple Developer account.

主机平台支持

🌐 Host platform support

安卓iOS 模拟器iPhone 设备
macOS
Windows
Linux

先决条件

1 要求

本地构建工具

为你要开发的平台设置开发环境:Android Studio 和模拟器 用于 Android,Xcode 和 iOS 模拟器 用于 iOS。

1

安装 expo-dev-client

🌐 Install expo-dev-client

在项目的根目录下运行以下命令:

🌐 Run the following command in your project's root directory:

Terminal
- npx expo install expo-dev-client
- yarn expo install expo-dev-client
- pnpm expo install expo-dev-client
- bun expo install expo-dev-client
你在现有的 React Native 项目中使用这个库吗?

不使用Continuous Native Generation的应用或使用npx react-native创建的应用,在安装此库后需要进一步配置。请参阅在现有 React Native 项目中安装expo-dev-client的步骤 1 和 2。

🌐 Apps that don't use Continuous Native Generation or are created with npx react-native, require further configuration after installing this library. See steps 1 and 2 from Install expo-dev-client in an existing React Native project.

开发版看起来什么样?
When you run a development build it will look like this, only with your app name and icon included rather than "RHT". The launcher UI is pictured in iOS on the left and Android on the right. In between, you can see an app running inside of the development build, with the customizable developer menu open.

2

构建并运行应用

🌐 Build and run the app

Terminal
- npx expo run:android
- yarn expo run:android
- pnpm expo run:android
- bun expo run:android

默认情况下,应用会安装在正在运行的 Android 模拟器上。对于实体设备,通过 USB 连接,提示时允许 USB 调试,然后加上 --device 标志。

🌐 By default the app installs on a running Android Emulator. For a physical device, plug it in via USB, allow USB debugging when prompted, and add the --device flag.

这个命令会运行 prebuild 来生成本地 android 和 ios 目录(如果它们不存在的话),然后编译应用、安装它,并启动开发服务器。

🌐 This command runs prebuild to generate the native android and ios directories if they don't exist, then compiles the app, installs it, and starts the development server.

3

本地代码有变时重建

🌐 Rebuild when native code changes

expo run:android|ios 命令在后续运行时会重复使用原生 android 和 ios 目录。当你只修改了应用的 TypeScript/JavaScript 代码时,不需要重新构建原生应用。相反,可以这样启动开发服务器:

🌐 The expo run:android|ios command reuses the native android and ios directories on later runs. When you only change your app's TypeScript/JavaScript code, there is no need to rebuild the native app. Instead, start the development server with:

Terminal
- npx expo start
- yarn expo start
- pnpm expo start
- bun expo start

你只需要在以下情况下重新生成原生目录(android 和 ios):

🌐 You only need to regenerate the native directories (android and ios) when:

  • 安装或更新包含本地代码的库
  • 更改你的 应用配置 (app.json)
  • 升级你的 Expo SDK 版本

在这些情况下,使用以下命令重新生成本地目录:

🌐 In these cases, regenerate the native directories with:

Terminal
- npx expo prebuild --clean
- yarn expo prebuild --clean
- pnpm expo prebuild --clean
- bun expo prebuild --clean

然后,使用更新的原生代码重新构建你的应用,命令如下:

🌐 Then, rebuild your app with the updated native code, with:

Terminal
- npx expo run:android
- yarn expo run:android
- pnpm expo run:android
- bun expo run:android

在你安装开发版本之后

🌐 After you install the development build

从你设备的主屏幕启动开发版本,然后从启动器屏幕连接到开发服务器,就可以开始开发你的应用了。想了解如何使用你的新版本,包括启动器屏幕、重建以及调试,请参阅 使用开发版本。关于开发版本和 Expo Go 的常见问题,包括在 Expo Go 中不能做的事情及原因,请参阅 常见问题。

🌐 Launch the development build from your device's Home screen and connect to a development server from the launcher screen to start working on your app. To learn how to use your new build, including the launcher screen, rebuilding, and debugging, see Use a development build. For common questions about development builds and Expo Go, including what you can't do in Expo Go and why, see the FAQ.

AI代理的 Expo 技能

🌐 Expo Skills for AI agents

如果你使用 AI 代理,安装 Expo Skills 来教它本页面的工作流程:

🌐 If you use an AI agent, install Expo Skills to teach it the workflows on this page:

expo-dev-client

Build and distribute Expo development clients locally or via TestFlight for internal testing.

eas-simulator

Run and control a user's app on a remote iOS/Android simulator hosted on EAS cloud.