Expo DevClient iconExpo DevClient

允许创建开发版本并包含有用开发工具的库。

Android
iOS
tvOS
Bundled version:
~6.0.20

expo-dev-client 为你的调试版本添加了各种实用的开发工具:

Expo 文档将包含 expo-dev-client 的调试构建称为 开发构建

🌐 Expo documentation refers to debug builds that include expo-dev-client as development builds.

安装

🌐 Installation

Terminal
npx expo install expo-dev-client

如果你要在一个已有的 React Native 应用中安装此组件,请先在你的项目中安装expo。然后,按照在已有的 React Native 项目中安装 expo-dev-client中的说明操作。

🌐 If you are installing this in an existing React Native app, start by installing expo in your project. Then, follow the instructions from Install expo-dev-client in an existing React Native project.

应用配置中的配置

🌐 Configuration in app config

如果你在项目中使用配置插件(连续原生生成(CNG)),你可以使用其内置的 配置插件 来配置开发客户端启动器。该插件允许你配置无法在运行时设置并且需要构建新的应用二进制文件才能生效的各种属性。如果你的应用使用 CNG,则需要手动配置该库。

🌐 You can configure development client launcher using its built-in config plugin if you use config plugins in your project (Continuous Native Generation (CNG)). The plugin allows you to configure various properties that cannot be set at runtime and require building a new app binary to take effect. If your app does not use CNG, then you'll need to manually configure the library.

Example app.json with config plugin

app.json
{ "expo": { "plugins": [ [ "expo-dev-client", { "launchMode": "most-recent" } ] ] } }

Configurable properties

NameDefaultDescription
launchMode"most-recent"

决定是启动最近打开的项目还是导航到启动器屏幕。

  • most-recent - 尝试直接启动之前打开的项目,如果无法连接,则回退到启动器屏幕。
  • launcher - 打开启动器屏幕。
addGeneratedSchemetrue

默认情况下,expo-dev-client 会注册一个自定义 URL 方案以打开项目。将此属性设置为 false 可禁用此方案。

电视支持

🌐 TV support

  • 此库仅在 SDK 54 及更高版本中支持 TV。
    • Android TV:支持所有操作,类似于安卓手机。
    • Apple TV:支持使用本地或隧道打包程序进行基本操作。目前尚不支持 EAS 的身份验证以及 EAS 构建和更新的列出功能。

应用接口

🌐 API

import * as DevClient from 'expo-dev-client';

Methods

DevClient.closeMenu()

Android
iOS
tvOS

A method that closes development client menu when called.

Returns:
void

DevClient.hideMenu()

Android
iOS
tvOS

A method that hides development client menu when called.

Returns:
void

DevClient.openMenu()

Android
iOS
tvOS

A method that opens development client menu when called.

Returns:
void

DevClient.registerDevMenuItems(items)

Android
iOS
tvOS
ParameterType
itemsExpoDevMenuItem[]

A method that allows to specify custom entries in the development client menu.

Returns:
Promise<void>

Types

ExpoDevMenuItem

Android
iOS
tvOS

An object representing the custom development client menu entry.

PropertyTypeDescription
callback() => void

Callback to fire, when user selects an item.

namestring

Name of the entry, will be used as label.

shouldCollapse(optional)boolean

A boolean specifying if the menu should close after the user interaction.

Default:false