首页指南参考教程

开发工具

Expo 工具和网站的概述,它们将帮助你完成项目构建过程的各个方面。


当你使用 Expo 创建新项目时,了解以下基本工具和网站可以帮助你完成应用开发之旅。此页面概述了推荐工具列表。

¥When you create a new project with Expo, learning about the following essential tools and websites can help you during your app development journey. This page provides an overview of a list of recommended tools.

Expo CLI

Expo CLI 是一种开发工具,当你创建新项目时会自动与 expo 包一起安装。你可以通过利用 npx(Node.js 包运行器)来使用它。

¥Expo CLI is a development tool and is installed automatically with expo package when you create a new project. You can use it by leveraging npx (a Node.js package runner).

它旨在帮助你在应用开发阶段更快地行动。例如,你与 Expo CLI 的第一次交互是通过运行以下命令启动开发服务器:npx expo start

¥It is designed to help you move faster during the app development phase. For example, your first interaction with Expo CLI is starting the development server by running the command: npx expo start.

以下是你在开发应用时将使用 Expo CLI 的常用命令列表:

¥The following is a list of common commands that you will use with Expo CLI while developing your app:

命令描述
npx expo start启动开发服务器(无论你使用的是开发版本还是 Expo Go)。
npx expo prebuild使用 预建 生成原生 Android 和 iOS 目录。
npx expo run:android在本地编译原生 Android 应用。
npx expo run:ios在本地编译原生 iOS 应用。
npx expo install package-name用于通过向此命令添加 --fix 选项来安装新库或验证和更新项目中的特定库。
npx expo lint设置和配置 ESLint。如果 ESLint 已配置,此命令将 本地与全局 URL 参数

简而言之,Expo CLI 允许你开发、编译、启动应用等。有关你可以使用 CLI 执行的更多可用选项和操作,请参阅 Expo CLI 参考

¥In a nutshell, Expo CLI allows you to develop, compile, start your app, and more. See Expo CLI reference for more available options and actions you can perform with the CLI.

EAS 命令行接口

¥EAS CLI

EAS CLI 用于登录你的 Expo 账户并使用不同的 EAS 服务(例如 Build、Update 或 Submit)编译你的应用。你还可以使用此工具来:

¥EAS CLI is used to log in to your Expo account and compile your app using different EAS services such as Build, Update, or Submit. You can also use this tool to:

  • 将你的应用发布到应用商店

    ¥Publish your app to the app stores

  • 创建应用的开发、预览或生产版本

    ¥Create a development, preview, or production build of your app

  • 创建无线 (OTA) 更新

    ¥Create over-the-air (OTA) updates

  • 管理你的应用凭据

    ¥Manage your app credentials

  • 为 iOS 设备创建临时配置文件

    ¥Create an ad hoc provisioning profile for an iOS device

要使用 EAS CLI,你需要通过运行以下命令在本地计算机上全局安装它:

¥To use EAS CLI, you need to install it globally on your local machine by running the command:

Terminal
npm install -g eas-cli

你可以在终端窗口中使用 eas --help 来了解有关可用命令的更多信息。有关完整参考,请参阅 eas-cli npm 页面

¥You can use eas --help in your terminal window to learn more about the available commands. For a complete reference, see eas-cli npm page.

Expo Doctor

Expo Doctor 是一个命令行工具,用于诊断 Expo 项目中的问题。要使用它,请在项目的根目录中运行以下命令:

¥Expo Doctor is a command line tool used to diagnose issues in your Expo project. To use it, run the following command in your project's root directory:

Terminal
npx expo-doctor

此命令执行检查并分析项目的代码库,以查找 应用配置 和 package.json 文件、依赖兼容性、配置文件和项目整体运行状况中的常见问题。检查完成后,Expo Doctor 会输出结果。

¥This command performs checks and analyzes your project's codebase for common issues in app config and package.json files, dependency compatibility, configuration files, and the overall health of the project. Once the check is complete, Expo Doctor outputs the results.

如果 Expo Doctor 发现问题,它会提供问题描述以及如何修复或在哪里寻求帮助的建议。

¥If Expo Doctor finds an issue, it provides a description of the problem along with advice on how to fix it or where to find help.

你还可以使用 npx expo-doctor --help 显示使用信息。

¥You can also use npx expo-doctor --help to display usage information.

Orbit

Orbit 是一款 macOS 和 Windows 应用,可实现:

¥Orbit is a macOS and Windows app that enables:

  • 在物理设备和模拟器上安装并启动来自 EAS 的构建。

    ¥Install and launch builds from EAS on physical devices and emulators.

  • 在 Android 模拟器或 iOS 模拟器上安装并启动来自 EAS 的更新。

    ¥Install and launch updates from EAS on Android Emulators or iOS Simulators.

  • 在 Android 模拟器或 iOS 模拟器上启动零食项目。

    ¥Launch snack projects on Android Emulators or iOS Simulators.

  • 使用本地文件安装和启动应用。Orbit 支持任何 Android .apk、iOS Simulator 兼容的 .app 或临时签名的应用。

    ¥Use local files to install and launch apps. Orbit supports any Android .apk, iOS Simulator compatible .app, or ad hoc signed apps.

  • 查看 EAS 仪表板中的固定项目列表。

    ¥See a list of pinned projects from your EAS dashboard.

安装

¥Installation

你可以使用 Homebrew for macOS 下载 Orbit,也可以直接从 GitHub 发布 下载。

¥You can download Orbit with Homebrew for macOS, or directly from the GitHub releases.

Terminal
brew install expo-orbit

如果你希望 Orbit 在你登录时自动启动,请单击菜单栏中的 Orbit 图标,然后单击“设置”并选择“登录时启动”选项。

¥If you want Orbit to start when you log in automatically, click on the Orbit icon in the menu bar, then Settings and select the Launch on Login option.

注意:Windows 版 Orbit 处于预览阶段,仅与 x64 和 x86 机器兼容。将来会添加对其他架构的兼容性。

¥Note: Orbit for Windows is in preview and is only compatible with x64 and x86 machines. Compatibility for other architectures will be added in the future.

你可以直接从 GitHub 发布 下载适用于 Windows 的 Orbit。

¥You can download Orbit for Windows directly from the GitHub releases.

Orbit 依赖于 macOS 和 Windows 上的 Android SDK,以及 macOS 上仅用于设备管理的 xcrun,这需要同时设置 安卓工作室Xcode

VS Code 的 Expo 工具

¥Expo Tools for VS Code

Expo Tools 是一个 VS Code 扩展,可在使用应用配置文件时改善你的开发体验。它为应用配置、EAS 配置、存储配置和 Expo Module 配置文件等文件提供自动补齐和智能感知等功能。

¥Expo Tools is a VS Code extension to improve your development experience when working with app config files. It provides features such as autocomplete and intellisense for files such as app config, EAS config, store config and Expo Module config files.

安装 Expo Tools VS Code 扩展

使用此链接安装扩展或直接在你的 VS Code 编辑器中搜索 Expo Tools。

你还可以使用它来调试你的应用,使用 VS Code 的内置调试器设置断点、检查变量、通过调试控制台执行代码等。有关如何使用此扩展进行调试,请参阅 使用 VS Code 进行调试

¥You can also use it to debug your app using VS Code's built-in debugger to set breakpoints, inspect variables, execute code through the debug console, and more. See Debugging with VS Code for how to use this extension for debugging.

使用测试原型小样和 Expo Go

¥Test prototypes with Snack and Expo Go

Snack

Snack 是一个浏览器内开发环境,其工作原理与 Expo Go 类似。这是共享代码片段和试验 React Native 的好方法,无需在计算机上下载任何工具。

¥Snack is an in-browser development environment that works similarly to Expo Go. It's a great way to share code snippets and experiment with React Native without downloading any tools on your computer.

要使用它,请转到 snack.expo.dev,在 App.js 中编辑 <Text> 组件,在右侧面板中选择一个平台(Android、iOS 或 Web)并实时查看更改。

¥To use it, go to snack.expo.dev, edit the <Text> component in App.js, choose a platform (Android, iOS, or web) in the right panel and see the changes live.

Expo

Expo 是一个免费的开源沙盒,用于学习和试验 React Native。它适用于 Android 和 iOS。

¥Expo Go is a free open-source, sandbox for learning and experimenting with React Native. It works with Android and iOS.

有关如何使用它的更多信息:

¥For more information on how to use it:

  • 单击 树摇动 转到“设置你的环境”指南

    ¥Click this link to go to Set up your environment guide

  • 在“你想在哪里开发?”下选择要开发的平台

    ¥Select a platform to develop under Where would you like to develop?

  • 在“你想如何开发?”下选择 Expo Go

    ¥Select Expo Go under How would you like to develop?

  • 按照该指南中描述的说明操作

    ¥Follow the instructions described in that guide

注意:不建议构建生产应用并将其分发到应用商店。请改用 开发构建

¥Note: Not recommended for building and distributing production apps to the app stores. Instead, use development builds.

What if I open a project with an unsupported SDK version?

在 Expo Go 中运行为不受支持的 SDK 版本创建的项目时,你将看到以下错误:

¥When running a project that was created for an unsupported SDK version in Expo Go, you'll see the following error:

"Project is incompatible with this version of Expo Go"

要解决此问题,建议将你的项目升级到 默认模板。如果你想了解如何操作,请参阅 将项目升级到新的 SDK 版本

¥To fix this, upgrading your project to a supported SDK version is recommended. If you want to learn how to do it, see Upgrade the project to a new SDK Version.

How do I upgrade my project from an unsupported SDK version?

有关升级到特定 SDK 版本的说明,请参阅 升级 Expo SDK 指南

¥See Upgrading Expo SDK guide for instructions for upgrading to a specific SDK version.

React Native 目录

¥React Native directory

当你使用开发版本创建项目时,任何与 React Native 兼容的库都可以在 Expo 项目中使用。

¥Any library that is compatible with React Native works in an Expo project when you use a development build to create your project.

reactnative.directory 是一个可搜索的 React Native 库数据库。如果你要查找的库未包含在 Expo SDK 中,请使用目录查找与你的项目兼容的库。

¥reactnative.directory is a searchable database for React Native libraries. If a library you are looking for is not included in Expo SDK, use the directory to find a compatible library for your project.

使用库

请参阅本指南以了解有关 React Native 核心库、Expo SDK 库和第三方库之间的区别的更多信息。它还解释了如何确定第三方库兼容性。

Expo 中文网 - 粤ICP备13048890号