This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
工具、工作流程和扩展
详细了解使用开发版本时可用的不同工具、工作流程和扩展。
开发版允许你快速迭代。但你可以扩展开发版的功能,以在团队协作时提供更好的开发体验,或根据需要自定义构建。
🌐 Development builds allow you to iterate quickly. However, you can extend the capabilities of your development build to provide a better developer experience when working in teams or customize the build to suit your needs.
工具
🌐 Tools
通道 URL
🌐 Tunnel URLs
有时,受限的网络条件会使连接开发服务器变得困难。npx expo start 命令可以将你的开发服务器暴露在一个公共可用的 URL 上,从而可以从全球各地通过防火墙访问。如果你无法通过默认的本地局域网选项连接到开发服务器,或者希望在开发过程中获取关于你的实现的反馈,这个选项会很有帮助。
🌐 Sometimes, restrictive network conditions make it difficult to connect to the development server. The npx expo start command exposes your development server on a publicly available URL that is accessible through firewalls from around the globe. This option is helpful if you are not able to connect to your development server with the default LAN option or if you want to get feedback on your implementation while you are developing.
要获取隧道 URL,请在命令行中将 --tunnel 标志 传递给 npx expo start。
🌐 To get a tunneled URL, pass the --tunnel flag to npx expo start from the command line.
已发布的更新
🌐 Published updates
EAS CLI 的 eas update 命令将当前的 JavaScript 和资源文件状态打包成优化的“更新”。该更新由 Expo 存储在托管服务上。应用的开发构建可以加载已发布的更新,而无需检出特定的提交或保持开发机器运行。
🌐 EAS CLI's eas update command bundles the current state of your JavaScript and asset files into an optimized "update". This update is stored on a hosting service by Expo. A development build of your app can load published updates without needing to check out a particular commit or leave a development machine running.
手动输入更新的 URL
🌐 Manually entering an update's URL
当开发版本启动时,它会显示用于加载开发服务器的界面,或者“手动输入 URL”。你可以手动提供一个 URL 来启动特定的分支。URL 的格式如下:
🌐 When a development build launches, it will expose UI to load a development server, or to "Enter URL manually". You can provide a URL manually that will launch a specific branch. The URL follows this pattern:
https://u.expo.dev/[your-project-id]?channel-name=[channel-name] # Example https://u.expo.dev/F767ADF57-B487-4D8F-9522-85549C39F43F?channel-name=main
要获取你项目的 ID,请使用 应用配置的 expo.updates.url 字段中的 URL。要查看通道列表,请运行 eas channel:list。
🌐 To get your project's ID, use the URL in the app config's expo.updates.url field. To see a list of channels, run eas channel:list.
深层链接到更新的 URL
🌐 Deep linking to an update's URL
你可以通过打开带有 __expo_url 查询参数的启动 URL,在拥有兼容开发版本的设备上加载你的应用。在 SDK 58 及更高版本中,URL 的格式如下:
🌐 You can load your app on a device that has a compatible development build by opening a launch URL that has the __expo_url query parameter. In SDK 58 and later, the URL has the following form:
{scheme}://?__expo_url={manifestUrl}
示例:
🌐 Example:
exp+app-slug://?__expo_url=https%3A%2F%2Fu.expo.dev%2F767ADF57-B487-4D8F-9522-85549C39F43F%2F%3Fchannel-name%3Dmain
在上面的例子中,scheme 是 exp+app-slug,而 manifestUrl 是一个 ID 为 F767ADF57-B487-4D8F-9522-85549C39F43F、通道为 main 的项目。
🌐 In the example above, the scheme is exp+app-slug, and the manifestUrl is a project with an ID of F767ADF57-B487-4D8F-9522-85549C39F43F and a channel of main.
__expo_url 是启动器的保留查询参数之一,这类参数都以 __expo_ 开头。在 URL 到达你的应用之前,启动器会处理任何至少包含一个 __expo_* 参数的 URL。所有保留参数都是可选且独立的。启动器会在你的应用接收 URL 之前将它们移除,所以它们永远不会到达你的应用的深度链接处理或开发服务器。
__expo_disable_fab 和 __expo_disable_auto_launch 只适用于已启动的进程,永远不会更改已保存的开发菜单设置。之后打开应用的人仍然会看到菜单和工具按钮。传统的 disableFab=1 和 disableAutoLaunch=1 参数会不断更新已保存的设置。
同样的参数也适用于 Expo Go 启动 URL,例如 exp://192.168.1.10:8081?__expo_disable_auto_launch=1。
🌐 The same parameters work on Expo Go launch URLs, for example exp://192.168.1.10:8081?__expo_disable_auto_launch=1.
信息 SDK 57 及更早版本只支持传统形式
{scheme}://expo-development-client/?url={manifestUrl}。传统形式以及与url放在一起的disableOnboarding=1、disableFab=1和disableAutoLaunch=1参数在 SDK 58 及更高版本中仍然有效,而npx expo start会生成__expo_url形式。
在自动化场景中使用启动 URL
🌐 Using launch URLs in automation scenarios
在使用自动化启动开发构建时,例如在 CI/CD 工作流、端到端测试或代理循环中,请在启动 URL 中添加 __expo_disable_onboarding=1、__expo_disable_fab=1 和 __expo_disable_auto_launch=1。在启动 Expo CLI 时设置 EXPO_NO_DEV_MENU=1,可以将这些参数添加到该会话的每个启动 URL、二维码和重定向中。默认情况下,当 Expo CLI 处于非交互模式时(比如在 CI 中或没有 TTY 时),会自动执行此操作。设置 EXPO_NO_DEV_MENU=0 可选择退出。
🌐 When launching a development build with automation, such as in a CI/CD workflow, an end-to-end test, or an agent loop, add __expo_disable_onboarding=1, __expo_disable_fab=1, and __expo_disable_auto_launch=1 to the launch URL. Set EXPO_NO_DEV_MENU=1 when you start Expo CLI to add these parameters to every launch URL, QR code, and redirect for that session. Expo CLI does this by default when it is not interactive, such as in CI or without a TTY. Set EXPO_NO_DEV_MENU=0 to opt out.
应用特定的深层链接
🌐 App-specific deep links
在测试开发版本中的深度链接时,例如在 Expo Router 应用中导航到特定屏幕或测试在 Oauth 登录流程中重定向回应用时,应像深度链接到应用的独立版本(例如 myscheme://path/to/screen)一样准确构建 URL。
🌐 When testing deep links in your development build, such as when navigating to a specific screen in an Expo Router app or testing redirecting back to your app during an Oauth login flow, construct the URL exactly as you would if you were deep-linking into a standalone build of your app (for example, myscheme://path/to/screen).
你的项目必须已经在开发版本中打开,应用专用深度链接才能正常工作。目前不支持通过应用专用深度链接冷启动开发版本。避免在应用专用深度链接的路径中使用 expo-development-client,因为它是用于启动更新 URL 的保留路径。
🌐 Your project must be already open in the development build for an app-specific deep link to work. Cold-launching a development build with an app-specific deep link is not currently supported. Avoid using expo-development-client in your app-specific deep links in the path, as it is a reserved path used for launching an updated URL.
二维码
🌐 QR codes
你可以使用我们的端点生成可以通过开发版本轻松加载的二维码。
🌐 You can use our endpoint to generate a QR code that can be easily loaded by a development build.
当向 https://qr.expo.dev/development-client 发送请求并提供像 appScheme 和 url 这样的查询参数时,将会收到一个响应,其中包含一个 SVG 图片的二维码,可以轻松扫描以加载你的项目开发版本。
🌐 Requests send to https://qr.expo.dev/development-client when supplied the query parameters such as appScheme and url will receive a response with an SVG image containing a QR code that can be easily scanned to load a version of your project in your development build.
示例:
🌐 Example:
https://qr.expo.dev/development-client?appScheme=exp%2Bapps-slug&url=https%3A%2F%2Fu.expo.dev%2FF767ADF57-B487-4D8F-9522-85549C39F43F0%3Fchannel-name%3Dmain
在上面的例子中,scheme 是 exp+app-slug,而 url 是一个 ID 为 F767ADF57-B487-4D8F-9522-85549C39F43F、通道为 main 的项目。
🌐 In the example above, the scheme is exp+app-slug, and the url is a project with an ID of F767ADF57-B487-4D8F-9522-85549C39F43F and a channel of main.
工作流程示例
🌐 Example workflows
以下是一些工作流程示例,旨在帮助你的团队充分利用开发版本。如果你想出了其他对其他团队有用的工作流程,提交一个 PR 与大家分享你的知识!
🌐 These are a few examples of workflows to help your team get the most out of your development build. If you come up with others that would be useful for other teams, submit a PR to share your knowledge!
PR 预览
🌐 PR previews
你可以将 CI 流程设置为在拉取请求更新时发布 EAS 更新,并添加用于查看兼容开发版本中的更改的 QR 代码。
🌐 You can set up your CI process to publish an EAS Update whenever a pull request is updated and add a QR code that is used to view the change in a compatible development build.
查看 在拉取请求上发布应用预览的说明,了解如何在项目中使用 GitHub Actions 实现此工作流程,或将其作为你选择的持续集成模板。
🌐 See instructions for publishing app previews on pull requests to implement this workflow in your project using GitHub Actions or serve as a template in your CI of choice.
扩展
🌐 Extensions
扩展允许你使用附加功能来扩展你的开发客户端。
🌐 Extensions allow you to extend your development client with additional capabilities.
扩展开发菜单
🌐 Extending the dev menu
可以使用 registerDevMenuItems API 扩展开发者菜单,以包含额外的按钮:
🌐 The dev menu can be extended to include extra buttons by using the registerDevMenuItems API:
import { registerDevMenuItems } from 'expo-dev-menu'; const devMenuItems = [ { name: 'My Custom Button', callback: () => console.log('Hello world!'), }, ]; registerDevMenuItems(devMenuItems);
这将在开发菜单中创建一个新部分,其中包含你已注册的按钮:
🌐 This will create a new section in the dev menu that includes the buttons you have registered:
registerDevMenuItems的后续调用将覆盖所有之前的条目。
EAS 更新
🌐 EAS Update
EAS 更新扩展提供在你的开发客户端中查看和加载已发布更新的功能。要安装它,你需要最新发布的 expo-updates:
🌐 The EAS Update extension provides the ability to view and load published updates in your development client. To install it, you'll need the most recent publish of expo-updates:
配置 EAS 更新
🌐 Configure EAS Update
如果你尚未在项目中配置 EAS 更新,可以在这里找到关于如何操作的详细说明。
🌐 If you have not yet configured EAS Updates in your project, you can find additional instructions on how to do so here.
你现在可以通过 Extensions 面板在开发版本中查看和加载 EAS 更新。
🌐 You can now view and load EAS Updates in your development build via the Extensions panel.
在应用配置中设置运行时版本
🌐 Set runtimeVersion in app config
当你创建项目的开发构建时,你将获得一个稳定的环境来加载由 JavaScript 或其他资源相关更改定义的应用更新。其他对应用的更改,无论是直接在 android 和 ios 目录中定义,还是通过你选择安装的包或 SDK 定义,都需要你创建一个新的开发构建版本。
🌐 When you create a development build of your project, you'll get a stable environment to load any changes to your app that are defined in JavaScript or other asset-related changes. Other changes to your app, whether defined directly in android and ios directories or by packages or SDKs you choose to install, will require you to create a new build of your development build.
为了在应用的 JavaScript 层和原生层之间强制执行 API 合约,你应该在应用配置中设置 runtimeVersion 值。每次构建都会将此值嵌入,并且只会加载具有相同 runtimeVersion 的包,无论是在开发环境还是生产环境中。
🌐 To enforce an API contract between the JavaScript and native layers of your app, you should set the runtimeVersion value in the app config. Each build you make will have this value embedded and will only load bundles with the same runtimeVersion, in both development and production.