首页指南参考教程

常见问题

有关 Expo 及相关服务的常见问题和限制列表。


本页列出了有关 Expo 及相关服务的一些常见问题和解答。如果此处未解答你的问题,请参阅 论坛 了解更多常见问题。

¥This page lists some of the common questions and answers about Expo and related services. If you have a question that is not answered here, see Forums for more common questions.

Expo 是用来做什么的?

¥What is Expo used for?

Expo 是一款 开源框架,适用于在 Android、iOS 和 Web 上原生运行的应用。Expo 汇集了移动和 Web 的优点,并支持构建和扩展应用的许多重要功能,例如实时更新、即时共享应用和网络支持。expo npm 包为 React Native 应用提供了一系列令人难以置信的功能。expo 包几乎可以安装在任何 React Native 项目中。请参阅 Expo 提供什么 了解更多信息。

¥Expo is an open-source framework for apps that run natively on Android, iOS, and the web. Expo brings together the best of mobile and the web and enables many important features for building and scaling an app such as live updates, instantly sharing your app, and web support. The expo npm package enables a suite of incredible features for React Native apps. The expo package can be installed in nearly any React Native project. See what Expo offers for more information.

公司使用 Expo 吗?

¥Do companies use Expo?

是的,Expo 被全球顶层公司使用,为数亿终端用户提供服务。看看我们的 showcase

¥Yes, Expo is used by top companies worldwide, serving hundreds of millions of end users. See our showcase.

为什么 Expo 有自己的 SDK?

¥Why does Expo have its own SDK?

当 Expo 首次创建时,React Native 尚未公开发布。这意味着没有第三方软件包。为了使 React Native 的开发者体验合理,我们创建了 几个库来实现通用功能。许多这样的库已经被分叉和修改以满足各种需求。我们欢迎用户混合搭配他们需要的任何 自定义原生代码,以使他们的应用变得更加出色。

¥When Expo was first created, React Native had yet to be publicly released. This means there were no third-party packages. To make React Native's developer experience reasonable, we created several libraries to achieve common functionalities. Many of these libraries have since been forked and modified to meet various needs. We welcome users to mix and match whichever custom native code they need to make their app great.

Expo SDK 经过充分测试,用 TypeScript 编写,有文档记录,并且专为 Android、iOS 和 Web 构建。Expo SDK 中的每个模块协同工作以确保版本控制始终匹配。这创造了良好的升级体验。

¥The Expo SDK is well-tested, written in TypeScript, documented, and built for Android, iOS, and the web. Every module in the Expo SDK works together to ensure versioning always matches. This creates a nice upgrading experience.

Expo SDK 也是用 Expo 原生 API 编写的,以便更轻松地贡献、维护和理解。

¥The Expo SDK is also written with the Expo native API to make contributing, maintaining, and understanding easier.

Expo 和 React Native 有什么区别?

¥What is the difference between Expo and React Native?

expo 包提供了一套功能,可以更轻松地开发和扩展复杂的 React Native 应用。你几乎可以在任何 React Native 应用中安装 expo。使用 Expo 应用服务(EAS) 或 React Native 不需要 expo 包,但是,强烈建议使用 expo 包。请参阅 Expo 提供什么 了解更多信息。

¥The expo package provides a suite of features that make it easier to develop, and scale complex React Native applications. You can install expo in nearly any React Native app. The expo package is not required to use Expo Application Services (EAS) or React Native, however, it is highly recommended. See what Expo offers for more information.

我需要从 React Native 切换到使用 Expo 吗?

¥Do I need to switch from React Native to use Expo?

不,expo npm 包和 CLI 可与任何 React Native 应用配合使用。Expo 应用服务(EAS) 还适用于所有 React Native 应用,对构建、更新、应用商店提交等提供一流的支持。

¥No, the expo npm package and CLI work with any React Native app. Expo Application Services (EAS) also works with all React Native apps with first-class support for builds, updates, app store submissions, and more.

Expo 花费多少钱?

¥How much does Expo cost?

Expo 平台为 免费和开源。这包括构成用于开发的 Expo SDKExpo CLI 的库。Expo Go 应用是最简单的入门方式,也可从应用商店免费获取。

¥The Expo platform is free and open source. This includes the libraries that make up the Expo SDK and the Expo CLI used for development. The Expo Go app, the easiest way to get started, is also free from the app stores.

Expo 应用服务(EAS) 是来自 Expo 团队的 React Native 应用的可选云服务套件。EAS 使你可以更轻松地构建应用、将其提交到商店、保持更新、发送推送通知等。如果 免费计划 配额足够你的应用使用,你可以免费使用 EAS。更多信息请参见 定价页面

¥Expo Application Services (EAS) is an optional suite of cloud services for React Native apps, from the Expo team. EAS makes it easier to build your app, submit it to the stores, keep it updated, send push notifications, and more. You can use EAS for free if the Free plan quotas are sufficient for your app. More information is available on the pricing page.

如何将自定义原生代码添加到我的 Expo 项目?

¥How do I add custom native code to my Expo project?

Expo 支持添加自定义原生代码并自定义该原生代码(Android/Xcode 项目)。要使用任何自定义原生代码,你可以创建 开发构建配置插件。我们确实建议尽可能使用 Expo SDK 中的模块,以便更轻松地升级并改善开发者体验。

¥Expo supports adding custom native code and customizing that native code (Android/Xcode projects). To use any custom native code, you can create a development build and config plugins. We do recommend using the modules in the Expo SDK when possible for easier upgrades and improved developer experience.

我可以在使用 React Native CLI 创建的应用中使用 Expo 吗?

¥Can I use Expo in the app that is created with React Native CLI?

是的!所有 Expo 工具和服务在任何 React Native 应用中都能很好地工作。例如,你可以使用 Expo SDKexpo-dev-client 和 EAS 构建、提交和更新的任何部分 - 它们效果很好!了解有关 在你的项目中安装 expo采用预构建设置 EAS 构建 的更多信息。

¥Yes! All Expo tools and services work great in any React Native app. For example, you can use any part of the Expo SDK, expo-dev-client and EAS Build, Submit, and Update — they work great! Learn more about installing expo in your project, adopting prebuild, and setting up EAS Build.

如何分享我的 Expo 项目?我可以将其提交到应用商店吗?

¥How do I share my Expo project? Can I submit it to the app stores?

共享项目的最快方法是使用 EAS 更新 发布并在 开发构建 中启动。这为你的应用提供了一个 URL;你可以与任何拥有 Android 或 iOS 版 开发构建 的人分享此 URL。URL 也可以在 Android 版 Expo Go 中打开。

¥The fastest way to share your project is to publish with EAS Update and launch in a development build. This gives your app a URL; you can share this URL with anybody who has the development build for Android or iOS. URLs can also be opened in Expo Go for Android.

准备就绪后,你可以创建生产版本(.aab 和 .ipa)以提交到应用商店。你可以使用 EAS 构建 在单个命令中构建应用,然后使用 EAS 提交 将其提交到商店。

¥When ready, you can create a production build (.aab and .ipa) to submit to the app stores. You can build your app in a single command with EAS Build and submit it to the stores with EAS Submit.

你还可以使用 内部分配 在 Android 上通过 APK 共享你的应用,在 iOS 上通过临时或企业配置共享你的应用。

¥You can also use internal distribution to share your app with an APK on Android and ad-hoc or enterprise provisioning on iOS.

我可以在 Windows 计算机上开发 iOS 应用吗?

¥Can I develop iOS apps on a Windows computer?

传统上,你需要 macOS 来开发 iOS 应用,但是,你可以使用 EAS 构建 在云中构建你的应用。你还可以使用 EAS 提交 将你的应用提交到商店。可以使用 Expo开发构建 在物理 iOS 设备上完成测试。

¥Traditionally you needed a macOS to develop iOS apps, however, you can use EAS Build to build your app in the cloud. You can also use EAS Submit to submit your app to the stores. Testing can be done on a physical iOS device using Expo Go or a development build.

Expo SDK 支持哪些版本的 Android 和 iOS?

¥What versions of Android and iOS are supported by the Expo SDK?

Expo SDK 支持 Android 5+ 和 iOS 13+。欲了解更多信息,请参阅 支持 Android 和 iOS 版本

¥Expo SDK supports Android 5+ and iOS 13+. For more information, see Support for Android and iOS versions.

"你好世界" expo 应用的最小大小是多少?

¥What is the minimal size of a "hello world" expo app?

使用纯 Expo 创建的最小生产应用小于 3 MB。对于 iOS,Expo 的目标是更新的最低 iOS 版本,以实现应用商店优化。

¥A bare minimum production app created using pure Expo is less than 3 MB. For iOS, Expo targets a newer minimum iOS version which enables app store optimizations.

如果你的应用中包含 expo 软件包,则它只会一次性为应用商店中应用的最终大小增加 1 MB。expo 包具有边际大小成本(例如,Android 上为 150 Kib)。其余的大小来自语言运行时(例如 Android 上的 Kotlin)。

¥If the expo package is included in your app, it only adds 1 MB one time to the final size of apps on app stores. The expo package has a marginal size cost (for example, 150 Kib on Android). The rest of the size comes from the language runtime (such as Kotlin on Android).

我可以将 Expo 与我的原生库一起使用吗?

¥Can I use Expo with my native library?

你可以通过使用 Swift 和 Kotlin 创建 自定义原生模块,将原生 Android 和 iOS 库与 Expo 结合使用。许多流行的库已经有自定义的原生模块。查看我们的 React Native 目录,找到适合你的用例的流行库。

¥You can use native Android and iOS libraries with Expo by creating a custom native module with Swift and Kotlin. Many popular libraries already have custom native modules. Check out our React Native directory to find popular libraries for your use case.

我可以将 Expo 与此网络库一起使用吗?

¥Can I use Expo with this web library?

许多流行的 Web 包(例如 Three.js)可与 Expo 和 React Native 配合使用。请参阅 Expo 实例 了解更多信息。

¥Many popular web packages such as three.js work with Expo and React Native. See Expo examples for more information.

Expo 与 Web 开发的 React 类似吗?

¥Is Expo similar to React for web development?

Expo 是一款 开源框架,适用于在 Android、iOS 和 Web 上原生运行的应用。React Native 与 Web 开发中的 react-dom 类似,使你能够在特定平台上运行 React,但是,它有一些关键区别:

¥Expo is an open-source framework for apps that run natively on Android, iOS, and the web. React Native is similar to react-dom from web development, enabling you to run React on a particular platform, however, it has a few key differences:

  • React Native 不支持 HTML 或 CSS。

    ¥React Native does not support HTML or CSS.

  • React Native 不使用 DOM,而是使用原生组件。例如,<View /> 而不是 <div />。原生组件比 DOM 性能更高,并提供更好的用户体验。

    ¥Instead of using the DOM, React Native uses native components. For example, <View /> instead of <div />. Native components are more performant than the DOM and provide a much nicer user experience.

  • 与可以访问浏览器 API 的 React.js 不同,React Native 使用自定义原生 API。例如,你使用 expo-location 代替 navigator.geolocation 来访问用户的位置。自定义原生 API 与浏览器 API 类似,只不过你可以完全控制它们。这意味着你可以在新功能在浏览器中可用之前访问它们。

    ¥Unlike React.js which has access to browser APIs, React Native uses custom native APIs. For example, instead of navigator.geolocation, you use expo-location to access the user's location. Custom native APIs are similar to browser APIs except you have full control over them. This means you can access new features before they are available in the browser.

就像 React.js 框架帮助用户轻松创建更大的网站一样,Expo 也帮助用户轻松创建更大的应用。Expo 提供了一套经过充分测试的 React Native 模块,可以在 Android、iOS 和 Web 上运行。Expo 还提供了 工具套件 用于构建、部署和更新你的应用。

¥In the same way React.js frameworks help users create larger websites with ease, Expo helps users create larger apps with ease. Expo provides a suite of well-tested React Native modules that run on Android, iOS, and the web. Expo also provides a suite of tools for building, deploying, and updating your app.

关于解释代码的商店政策是什么?

¥What are the store policies regarding interpreted code?

React Native 使用 JavaScript 解释器(JSC、V8 或 Hermes)来运行你的应用代码。直接参考 Google Play 政策中心Apple 开发者计划许可协议 了解最新的政策信息。

¥React Native uses a JavaScript intepreter (JSC, V8, or Hermes) to run your application code. Refer to the Google Play Policy Center and Apple Developer Program License Agreement directly for the most up-to-date policy information.

以下是截至 2024 年 4 月 25 日的相关政策摘录。

¥The following are excerpts of related policies, as of April 25, 2024.

谷歌应用商店

¥Google Play Store

...an app may not download executable code (such as dex, JAR, .so files) from a
source other than Google Play. This restriction does not apply to code that runs
in a virtual machine or an interpreter where either provides indirect access to
Android APIs (such as JavaScript in a webview or browser).

Apps or third-party code, like SDKs, with interpreted languages (JavaScript,
Python, Lua, etc.) loaded at run time (for example, not packaged with the app)
must not allow potential violations of Google Play policies.

来源:Google Play 政策中心

¥Source: Google Play Policy Center.

苹果应用商店

¥Apple App Store

...Interpreted code may be downloaded to an Application but only so long as such code:
(a) does not change the primary purpose of the Application by providing features
    or functionality that are inconsistent with the intended and advertised purpose
    of the Application as submitted to the App Store,
(b) does not create a store or storefront for other code or applications, and
(c) does not bypass signing, sandbox, or other security features of the OS.

来源:3.3.1 API 和功能 - B. 可执行代码

¥Source: 3.3.1 APIs and Functionality - B. Executable Code.

我应该使用 Expo CLI 还是 React Native Community CLI?

¥Should I use Expo CLI or React Native Community CLI?

Expo CLI 可以与 React Native Community CLI(有时也称为 "React Native CLI")同时使用。Expo CLI 提供与 React Native CLI 相同的核心功能,以及自动 TypeScript 设置网络支持自动安装兼容库改进的原生构建命令tunnelingprebuild和更多 等附加功能。

¥Expo CLI can be used simultaneously with React Native Community CLI (also sometimes referred to as "React Native CLI"). Expo CLI provides the same core functionality as React Native CLI, and additional functionality like automatic TypeScript setup, web support, auto installing compatible libraries, improved native build commands, tunneling, prebuild, and more.

无论你使用哪种 CLI,你都可以在项目中使用 Expo SDKExpo 应用服务 的任何部分。

¥Regardless of which CLI you use, you can use any part of the Expo SDK and Expo Application Services with your project.

了解有关你可能想要使用 Expo CLI 的原因的更多信息

¥Learn more about why you might want to use Expo CLI.

Expo Go 是开源的吗?

¥Is Expo Go open source?

是的,Expo Go 的源代码可以在 apps/expo-go 目录的 expo/expo GitHub 存储库 中找到。Expo Go 应用也是使用 Expo 和 React Native 构建的。

¥Yes, the source for Expo Go can be found in the expo/expo GitHub repository in the apps/expo-go directory. The Expo Go app is also built with Expo and React Native.

Expo 弹出是否已弃用?

¥Is Expo eject deprecated?

是的,Expo 弹出是一个已弃用的术语,不再需要。它被 npx expo prebuild 命令取代,该命令根据项目中的库和应用配置 (app.json) 不断为你生成原生项目。在 Expo 预建文档 中了解更多信息。

¥Yes, Expo eject is a deprecated term and is no longer necessary. It was replaced by the npx expo prebuild command which continuously generates native projects for you based on the libraries in your project and the app config (app.json). Learn more in the Expo Prebuild documentation.

expo eject 库不同,作者可以通过创建 配置插件 来配置其库以与 Expo Prebuild 配合使用。这意味着你可以将任何库与 Expo Prebuild 一起使用。你还可以通过创建 开发构建 文件来将任何自定义原生代码与 Expo Prebuild 结合使用。

¥Unlike the expo eject library, authors can configure their libraries to work with Expo Prebuild by creating a config plugin. This means you can use any library with Expo Prebuild. You can also use any custom native code with Expo Prebuild by creating a development build.

局限性

¥Limitations

以前,Expo 具有较大的原生二进制文件大小,并且不支持没有 "ejecting" 的自定义原生代码。2020 年 12 月,当我们发布支持任何 React Native 应用的 EAS 构建 时,这些问题就消失了。"ejecting" 的概念已被流行的 Expo 预建 功能所取代,该功能自 SDK 41(2021 年 4 月)以来一直存在。Expo SDK 46 中的 expo eject 命令已完全弃用(2022 年 8 月)。

¥Previously, Expo had large native binary sizes and didn't support custom native code without "ejecting". These issues went away in December 2020 when we released EAS Build which supports any React Native app. The concept of "ejecting" was replaced by the popular Expo Prebuild feature which has been around since SDK 41 (April 2021). The expo eject command was fully deprecated in Expo SDK 46 (August 2022).

我们相信 Expo 工具对于任何想要快速创建令人惊叹的跨平台应用的人来说都是一个不错的选择。尽管如此,每个人的项目都是独一无二的,并且可能有一些原因 Expo 不是你正在构建的项目的正确选择。下面列出了你可能不想在项目中使用某些 Expo 工具的原因:

¥We believe Expo tools are a great option for anyone looking to create amazing cross-platform apps quickly. Nonetheless, everyone's project is unique, and there may be reasons Expo is not the right choice for what you're building. Reasons, why you may not want to use certain Expo tools with your project, are listed below:

EAS

有关 EAS 当前存在的限制的更多信息,请参阅以下内容:

¥For more information on what current limitations exist with EAS, see the following:

EAS 构建

EAS Build 旨在适用于任何 React Native 项目,无论你是否也使用 Expo Prebuild 或管理自己的原生文件。 在某些情况下,你可能需要更改项目配置,或者它可能与你的应用不兼容。 了解更多。

EAS 更新

EAS Update 是一项托管服务,使用 expo-updates 库为项目提供更新。 你可以使用它来修复小错误,并在应用商店提交之间快速推送快速修复。 在某些情况下,不适合项目。 了解更多。

EAS 元数据

EAS 元数据可帮助使用一个配置文件尽可能轻松地在商店中创建或维护应用。 在某些情况下,不适合项目。 了解更多。

通知

无论你正在构建哪种类型的应用,推送通知都是一项重要功能。 在某些情况下,你可能想了解使用 Expo 设置推送通知时的常见问题。 了解更多。

裸工作流程

¥Bare workflow

开发构建 类似,裸工作流程还提供对底层原生项目和任何原生代码的访问。这是一个 "bare" 原生项目,你可以直接更改项目的原生 android 和 ios 目录,而不是使用 应用配置和预构建 按需不断生成它们。

¥Similar to development builds, the bare workflow also provides access to the underlying native projects and any native code. It's a "bare" native project where you can make direct changes to the project's native android and ios directories rather than continuously generating them on demand using the app config and prebuild.

如果你签入原生目录,EAS Build 与裸工作流项目兼容,但不再运行预构建,因为这可能会覆盖你对原生项目文件所做的任何手动自定义。你必须使用 Android Studio 或 Xcode 等原生工具自行配置原生目录。

¥EAS Build is compatible with bare workflow projects if you check in the native directories, but no longer runs prebuild, as that could overwrite any manual customizations you have made to the native project files. You'll have to configure the native directories on your own with native tools such as Android Studio or Xcode.

Expo

Expo 提供了一种快速开始应用开发的方法。它附带了一组预配置的库,称为 Expo SDK。这使得实验速度更快,并使移动开发体验更接近 Web 开发体验。

¥Expo Go provides a quick way to get started with your app development. It comes with a pre-configured set of libraries known as the Expo SDK. This makes experimentation much faster and brings the mobile development experience much closer to the web development experience.

与任何其他工具一样,它也有其局限性:

¥Like any other tool, it too has its limitations:

  • 使用需要原生代码的第三方库

    ¥Using a third-party library that requires native code

  • 使用第三方推送通知服务

    ¥Using a third-party push notification service

我们强烈建议任何需要带有原生代码的附加库的项目迁移到 开发构建。这就像创建一个专门根据你的应用需求定制的 Expo Go 版本。

¥We strongly recommend any projects that require additional libraries with native code to migrate to development builds. It's like creating a version of Expo Go that is specifically customized to your app's needs.

Expo 中文网 - 粤ICP备13048890号