将 Expo 工具集成到现有的原生应用中

概述如何将 Expo 工具集成到现有原生应用 ("brownfield" 应用) 中。


使用其他技术构建的现有原生应用,其主要入口点不是 React Native 视图,通常称为 "brownfield" 应用。例如,如果你的应用是使用 UIKit 和 Swift 构建的,并且你想在单个屏幕上使用 React Native,那么这将被视为 "现有的原生应用" 和 "brownfield"。

¥An existing native app that was built using another technology, whose main entry point is not a React Native view, is commonly referred to as a "brownfield" app. For example, if your app was built using UIKit and Swift, and you want to use React Native for a single screen then that is considered an "existing native app" and "brownfield".

相比之下,"greenfield" 应用从一开始就使用 Expo 或 React Native 创建,或者 React Native 是入口点,所有其他 UI 都从这里分支。

¥In contrast, "greenfield" apps are created using Expo or React Native from the start or where React Native is the entry point and where all other UI branches off from.

根据这些定义,如果你有适用于 Android 或 iOS 的 "现有的原生应用",并且想要学习如何在项目中使用 Expo 和 React Native(可能在单个屏幕上,甚至单个功能上),那么本指南适合你。

¥By these definitions, if you have an "existing native app" for Android or iOS and you want to learn how to use Expo and React Native in your project (perhaps on a single screen or even a single feature), then this guide is for you.

与现有原生应用的兼容性

¥Compatibility with existing native apps

将 Expo 模块集成到现有原生项目的支持仍处于试验阶段。如果你遇到问题,在 GitHub 上创建问题。在现有原生应用环境中使用时,以下工具和服务的某些功能并非全部可用。

Expo 主要为绿地应用而构建,但我们越来越多地投资于棕地场景。并非所有 Expo 工具和服务都与现有的原生项目兼容。此外,棕地集成的全面文档可能尚未提供,你可能需要根据你的情况调整其他相关文档。

¥Expo is primarily built with greenfield apps in mind, but we are increasingly investing in brownfield scenarios. Not all Expo tools and services are compatible with existing native projects yet. Additionally, comprehensive documentation for brownfield integrations may not yet available, and you may need to adapt other related documentation to your context.

工具/服务支持 brownfield?
Expo SDK - React Native 的扩展标准库
Expo 模块 API - 使用惯用的 Swift/Kotlin API 构建原生扩展
Expo 路由 - 基于文件的路由和导航
Expo CLI - 从终端运行和开发应用的工具
Expo 开发客户端 - 将应用内开发者工具添加到 Debug 版本
EAS 构建 - 专为 Expo/React Native 构建的 CI/CD 服务
EAS 提交 - 将你的应用上传到商店的托管服务
EAS 更新 - 即时更新你的应用 JavaScript 和资源

下一步

¥Next steps

集成你的第一个 React Native 视图

了解如何在 React Native 文档中将 React Native 根视图添加到你现有的原生应用。

安装 Expo 模块

安装 Expo 模块 API 并使用它来添加现有的 Expo 模块或编写你自己的原生扩展。