开发工具
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 the 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:
| Command | Description |
|---|---|
npx expo start | Starts the development server (whether you are using a development build or Expo Go). |
npx expo prebuild | Generates native Android and iOS directories using Prebuild. |
npx expo run:android | Compiles native Android app locally. |
npx expo run:ios | Compiles native iOS app locally. |
npx expo install package-name | Used to install a new library or validate and update specific libraries in your project by adding --fix option to this command. |
npx expo lint | Setup and configures ESLint. If ESLint is already configured, this command will lint your project files. |
简而言之,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:
- 将你的应用发布到应用商店
- 创建应用的开发、预览或生产版本
- 创建无线 (OTA) 更新
- 管理你的应用凭据
- 为 iOS 设备创建临时配置文件
要使用 EAS CLI,你需要通过运行以下命令在本地计算机上全局安装它:
🌐 To use EAS CLI, you need to install it globally on your local machine by running the command:
- 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:
- 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.
默认情况下,Expo Doctor 会根据 React Native 目录 验证你项目的包,并在存在原生目录时检查应用配置属性是否正确同步。你可以在项目的 package.json 文件中配置这些检查。更多详情请参见 reactNativeDirectoryCheck 和 appConfigFieldsNotSyncedCheck。
🌐 By default, Expo Doctor validates your project's packages against the React Native directory and checks if app config properties are properly synced when native directories exist. You can configure these checks in your project's package.json file. See reactNativeDirectoryCheck and appConfigFieldsNotSyncedCheck for more details.
你也可以使用 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 的构建。
- 在 Android 模拟器或 iOS 模拟器上安装并启动来自 EAS 的更新。
- 在 Android 模拟器或 iOS 模拟器上启动零食项目。
- 使用本地文件安装和启动应用。Orbit 支持任何 Android .apk、iOS 模拟器兼容的 .app 或临时签名的应用。
- 查看 EAS 仪表板中的固定项目列表。
安装
🌐 Installation
你可以通过 Homebrew 在 macOS 上下载 Orbit,或者直接从 GitHub 发布页面 下载。
🌐 You can download Orbit with Homebrew for macOS, or directly from the GitHub releases.
- 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 机器。其他架构的兼容性将于未来添加。
你可以直接从 GitHub 发布页面 下载适用于 Windows 的 Orbit。
🌐 You can download Orbit for Windows directly from the GitHub releases.
信息 Orbit 在 macOS 和 Windows 上都依赖 Android SDK,而仅在 macOS 上依赖
xcrun进行设备管理,这需要同时设置 Android Studio 和 Xcode。
VS Code 的 Expo 工具
🌐 Expo Tools for VS Code
Expo Tools 是一个 VS Code 扩展,用于在处理应用配置文件时提升你的开发体验。它提供了诸如自动补齐和智能感知(IntelliSense)等功能,适用于应用配置、EAS 配置、存储配置和 Expo 模块配置文件等文件。
🌐 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.
使用此链接安装扩展,或直接在 VS Code 编辑器中搜索 Expo 工具。
你也可以使用它通过 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.
使用测试 Snack 和 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 或网页),然后即可实时查看更改。
🌐 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 Go
Expo Go 是一个免费的开源平台,供学生和学习者尝试 React Native。它适用于 Android 和 iOS。
有关如何使用它的更多信息:
🌐 For more information on how to use it:
- 点击此链接查看设置环境指南
- 在 你想在哪里开发? 下选择一个开发平台
- 在 你想如何开发? 下选择 Expo Go
- 按照该指南中描述的说明操作
注意: Expo Go 功能有限,不适合用于构建生产级项目。请改用 开发版本。
如果我用不支持的 SDK 版本打开项目,会怎么样?
在 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 版本。如果你想了解如何操作,请参阅将项目升级到新的 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.
我该如何将我的项目从不受支持的 SDK 版本升级?
请参阅 升级 Expo SDK 指南 获取升级到特定 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 中,可以使用该目录为你的项目找到兼容的库。
查看此指南以了解 React Native 核心库、Expo SDK 库和第三方库之间的区别。它还解释了如何确定第三方库的兼容性。