首页指南参考教程

为应用商店构建你的项目

了解如何使用 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.

使用 EAS 进行生产构建

¥Production builds using EAS

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

¥Production builds must be installed through their respective app stores. They cannot be installed directly on your Android Emulator or device, or iOS Simulator 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 that 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")来将消息附加到构建。该消息将出现在网站上。当你想为你的团队留下关于构建目的的注释时,它会派上用场。

¥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 website. It comes in handy when you want to leave a note with 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 release 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 will need to have 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 does 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, you can let EAS CLI take care of that for you 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 开发者计划账户并按照提示操作,让 EAS CLI 为你处理这些事情。

    ¥If you have not generated a provisioning profile and/or distribution certificate yet, you can let EAS CLI take care of that for you by signing into 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. Monitor the progress and read the logs by following the link to the build details page that EAS CLI prompts once the build process gets started. 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.

生产在本地进行

¥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 that are required 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 时,请使用 npx expo run:android --variant release 命令而不是 npx react-native build-android --mode=release

¥Note: Following the guide below, in step four, when you build the release .aab for Android, use npx expo run:android --variant release command instead of npx react-native build-android --mode=release.

发布到 Google Play 商店

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

发布到 Apple App Store

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

下一步

¥Next step

应用商店最佳实践

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

Expo 中文网 - 粤ICP备13048890号