为应用商店构建你的项目

了解如何为你的应用创建生产版本,该版本已准备好使用 EAS Build 从命令行提交到应用商店。


无论你是使用 EAS 还是 locally 构建了原生应用二进制文件,应用开发之旅的下一步都是将你的应用提交到商店。为此,你需要创建一个生产版本。

¥Whether you have built a native app binary using EAS or locally, the next step in your app development journey is to submit your app to the stores. To do so, you need to create a production build.

生产版本提交到应用商店,向公众发布或作为商店辅助测试流程(如 TestFlight)的一部分。本指南介绍如何使用 EASlocally 创建生产版本。还可以使用任何能够编译 Android 和 iOS 应用的 CI 服务为 Expo 应用创建生产版本。

¥Production builds are submitted to app stores for release to the general public or as part of a store-facilitated testing process such as TestFlight. This guide explains how to create production builds with EAS and locally. It is also possible to create production builds for Expo apps with any CI service capable of compiling Android and iOS apps.

推进推出

¥Production builds using EAS

生产版本必须通过各自的应用商店安装。你无法直接将它们安装在你的 Android 模拟器、iOS 模拟器或设备上。唯一的例外是,如果你在构建配置文件中明确为 Android 设置了 "buildType": "apk"。但是,建议在提交到商店时使用 aab,这是默认配置。

¥Production builds must be installed through their respective app stores. You cannot install them directly on your Android Emulator, iOS Emulator, or device. The only exception to this is if you explicitly set "buildType": "apk" for Android on your build profile. However, it is recommended to use aab when submitting to stores, and this is the default configuration.

eas.json 配置

¥eas.json configuration

当你创建第一个构建时,已经在 eas.json 中创建了用于构建生产构建的最小配置:

¥A minimal configuration for building a production build in eas.json is already created when you create your first build:

eas.json
{
  "build": {
    %%placeholder-start%%... %%placeholder-end%%
    "production": {}
    %%placeholder-start%%... %%placeholder-end%%
  }
}

创建生产版本

¥Create a production build

要创建生产版本,请为平台运行以下命令:

¥To create a production build, run the following command for a platform:

Terminal
eas build --platform android
Terminal
eas build --platform ios

你可以通过将 --message 传递给构建命令(例如 eas build --platform ios --message "Some message")来将消息附加到构建。该消息将显示在 Expo 仪表板上。当你想要为你的团队指定构建目的时,它会派上用场。

¥You can attach a message to the build by passing --message to the build command, for example, eas build --platform ios --message "Some message". The message will appear on the Expo dashboard. It comes in handy when you want to specify the purpose of the build for your team.

或者,你可以使用 --platform all 选项同时为 Android 和 iOS 构建:

¥Alternatively, you can use --platform all option to build for Android and iOS at the same time:

Terminal
eas build --platform all

开发者账户

¥Developer account

你需要拥有要提交应用的应用商店的开发者账户。

¥You will need to have a developer account for the app store you want to submit your app.

Google Play Developer membership is required to distribute to the Google Play Store.

你可以使用 EAS Build 构建并签署你的应用,但无法将其上传到 Google Play 商店,除非你拥有成员资格(一次性费用为 25 美元)。

¥You can build and sign your app using EAS Build, but you can't upload it to the Google Play Store unless you have a membership, a one-time $25 USD fee.

Apple Developer Program membership is required to build for the Apple App Store.

如果你要使用 EAS Build 为 Apple App Store 创建生产版本,则需要访问具有 99 美元 苹果开发者计划 会员资格的账户。

¥If you are going to use EAS Build to create production builds for the Apple App Store, you need access to an account with a $99 USD Apple Developer Program membership.

应用签名凭据

¥App signing credentials

在应用商店开始构建过程之前,你需要一个商店开发者账户并生成或提供应用签名凭据。

¥Before the build process can start for app stores, you need a store developer account and generate or provide app signing credentials.

无论你是否有生成应用签名凭据的经验,EAS CLI 都可以完成繁重的工作。你可以选择 EAS CLI 来处理应用签名凭据流程。

¥Whether you have experience with generating app signing credentials or not, EAS CLI can do the heavy lifting. You can opt-in for EAS CLI to handle the app signing credentials process.

Android 应用签名凭据

¥Android app signing credentials

  • 如果你尚未为你的应用生成密钥库,请通过选择 Generate new keystore 使用 EAS CLI,然后你就完成了。密钥库安全地存储在 EAS 服务器上。

    ¥If you have not yet generated a keystore for your app, use EAS CLI by selecting Generate new keystore, and then you are done. The keystore is stored securely on EAS servers.

  • 如果你想手动生成密钥库,请参阅 手动 Android 凭证指南 了解更多信息。

    ¥If you want to manually generate your keystore, see the manual Android credentials guide for more information.

iOS 应用签名凭据

¥iOS app signing credentials

  • 如果你尚未生成配置文件和/或分发证书,请通过登录你的 Apple Developer Program 账户并按照提示使用 EAS CLI。

    ¥If you have not generated a provisioning profile and/or distribution certificate yet, use EAS CLI by signing in to your Apple Developer Program account and following the prompts.

  • 如果你想手动生成凭据,请参阅 手动 iOS 凭据指南 了解更多信息。

    ¥If you want to manually generate your credentials, see the manual iOS credentials guide for more information.

等待构建完成

¥Wait for the build to complete

默认情况下,eas build 命令将等待构建完成,但如果你不想等待,可以中断它。相反,使用 EAS CLI 提示的构建详细信息页面链接来监视构建进度并阅读构建日志。你也可以通过访问 你的构建仪表板 或运行以下命令找到该页面:

¥By default, the eas build command will wait for your build to complete, but you can interrupt it if you prefer not to wait. Instead, use the builds details page link prompted by EAS CLI to monitor the build progress and read the build logs. You can also find this page by visiting your build dashboard or running the following command:

Terminal
eas build:list

如果你是某个组织的成员并且你的构建代表该组织,你将在 该账户的构建仪表板 上找到构建详细信息。

¥If you are a member of an organization and your build is on its behalf, you will find the build details on the build dashboard for that account.

使用 EAS 的生产版本

¥Production builds locally

要在本地创建生产版本,请参阅以下 React Native 指南,了解有关 Android 和 iOS 所需步骤的更多信息。

¥To create a production build locally, see the following React Native guides for more information on the necessary steps for Android and iOS.

这些指南假设你的项目具有包含相应原生项目的 android 和/或 ios 目录。如果你使用 持续的原生生成,则需要运行 prebuild 来生成目录,然后再按照指南进行操作。

¥These guides assume your project has android and/or ios directories containing the respective native projects. If you use Continuous Native Generation then you will need to run prebuild to generate the directories before following the guides.

注意:按照以下指南,在第四步中,当你为 Android 构建发布 .aab 时,从 android 目录运行 ./gradlew app:bundleRelease 而不是 npx react-native build-android --mode=release

¥Note: Following the guide below, in step four, when you build the release .aab for Android, run ./gradlew app:bundleRelease from the android directory instead of npx react-native build-android --mode=release.

推送通知

了解如何通过手动执行必要的步骤将应用发布到 Google Play Store。

发布到 Google Play Store

了解如何通过手动执行必要的步骤将应用发布到 Apple App Store。

下一步

¥Next step

应用商店最佳实践

了解将你的应用提交到应用商店的最佳实践。