首页指南参考教程

开发构建简介

为 React Native 应用提供更好的开发环境。


开发版本是包含 expo-dev-client 包的应用的调试版本。通过使用开发版本而不是 Expo,你可以完全控制原生运行时,因此你可以使用 安装任何原生库修改任何项目配置编写自己的原生代码。通过 Expo 开发构建,你可以构建自己的原生应用,而通过 Expo Go,你可以在沙盒原生应用环境中运行你的项目。

¥A development build is a debug build of your app that contains the expo-dev-client package. By using development builds instead of Expo Go, you gain full control over the native runtime, so you can install any native libraries, modify any project configuration, or write your own native code. With Expo development builds, you are building your own native app, while with Expo Go you are running your project in a sandboxed native app environment.

When you run a development build it will look like this, only with your app name and icon included rather than "Microfoam". 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.

expo-dev-client 包替换了 React Native 随 更强大、可扩展的应用内 UI 提供的默认应用内开发工具 UI,添加了 支持网络调试,添加了对 启动更新(例如从 PR 预览 开始)的支持,并添加了启动器 UI。

¥The expo-dev-client package replaces the default in-app development tools UI that React Native provides with a more powerful and extensible in-app UI, adds support for network debugging, adds support for launching updates (such as from PR previews), and adds a launcher UI.

启动器 UI 可以在开发服务器之间切换,而无需重建应用二进制文件。这与 持续的原生生成 (CNG) 配合得很好,因为每当你修改应用中的原生代码时,你都可以生成单个开发版本,然后你可以迭代 JavaScript 代码,而无需重建原生代码,直到下次需要修改它为止。它在没有 CNG 的情况下也能很好地工作 - 这种方法非常适合拥有专门从事原生运行时工作的原生工程师的团队和专门使用原生应用对 实现类似网络的迭代速度 进行 React 的应用开发者,无需妥协。

¥The launcher UI makes it possible to switch between development servers without needing to rebuild the app binary. This works great alongside Continuous Native Generation (CNG) because you can generate a single development build whenever you modify the native code in your app, and then you can iterate on the JavaScript code without needing to rebuild the native code until the next time that you need to modify it. It also works great without CNG — this approach is very well suited to teams that have specialized native engineers who work on the native runtime and application developers that specialize in React to achieve web-like iteration speeds with native apps, without compromise.

开始使用 EAS Build 进行开发构建

开始开发构建的最简单方法是使用 EAS Build 在云中构建应用,因为你不需要在本地安装任何原生构建工具。

开始在本地开发环境中进行开发构建

本指南涵盖了构建开发应用的基础知识,并提供了有关如何配置环境的说明。

使用 Expo 开发应用

概述构建 Expo 应用的开发过程,以帮助构建核心开发循环的思维模型。 查看开发构建的适合位置。

"What's an Expo Development Build?"

一个 YouTube 视频,解释什么是开发构建以及如何使用它。

常见问题

¥Frequently asked questions

What is a native runtime?

原生运行时是指执行 JavaScript 应用代码的运行时环境。如果你的开发版本是在安装了 expo-camera 的情况下编译的,则原生运行时将包含适当的代码,以便你可以从 JavaScript 访问该功能。如果构建不是使用 expo-camera 编译的,那么你无法从 JavaScript 代码访问该代码。不同版本的应用运行时通过 运行时版本 配置字段进行管理。

¥A native runtime refers to the runtime environment that your JavaScript application code is executed in. If your development build is compiled with expo-camera installed, the native runtime will include the appropriate code so that you can access that functionality from JavaScript. If the build was not compiled with expo-camera, then you cannot access that code from your JavaScript code. Different versions of your app runtime are managed with a runtime version configuration field.

How are development builds different from Expo Go?

当你使用 Expo 开始一个新项目时,达到 "你好世界!" 的最快、最简单的方法是在你的设备上使用 Expo,因为你不需要编译任何原生代码或安装任何原生工具。

¥When you start a new project with Expo, the fastest and easiest way to get to "Hello, world!" is with Expo Go on your device because you don't need to compile any native code or install any native tooling.

除了 "你好世界!" 和原型之外,你很快就会遇到限制,并且需要构建应用的开发版本。例如,Expo Go 沙盒环境仅限于 Expo SDK 中包含的原生包,而你可以在开发版本中包含任何库,因为它只是一个普通的原生应用。

¥Beyond "Hello, world!" and prototypes, you'll quickly encounter limitations and need to build a development build of your app. For example, the Expo Go sandbox environment is limited to only the native packages included in the Expo SDK, while you can include any library in a development build because it's just a normal native app.

你可以将开发版本视为完全可定制的 Expo Go 版本,专为你的项目量身定制。或者,相反,Expo Go 是一个具有预设运行时间的开发环境。

¥You can think of a development build as your fully customizable version of Expo Go, tailored specifically for your project. Or, conversely, Expo Go is a development environment with a preset runtime.

What other types of builds are there?
  • 生产构建 面向普通大众,通过商店部署。

    ¥A production build is for the general public, deployed through stores.

  • 预览版本 可让你的团队通过直接在 Android 上安装 APK 或在 iOS 上使用临时或企业配置来测试你的下一个版本。

    ¥A preview build lets your team test your next release, either by installing an APK directly on Android or using ad hoc or enterprise provisioning on iOS.

Expo 中文网 - 粤ICP备13048890号