为应用商店构建你的项目
了解如何为你的应用创建生产版本,该版本已准备好使用 EAS Build 从命令行提交到应用商店。
无论你是使用 EAS 还是 本地 构建了原生应用二进制文件,你的应用开发之旅的下一步是将应用提交到应用商店。为此,你需要创建一个生产版本构建。
🌐 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)的一部分。本指南说明了如何使用 EAS 和 本地 创建生产版本。也可以使用任何能够编译 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:
{ "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:
- eas build --platform android- eas build --platform ios你可以通过在构建命令中传递 --message 来附加消息,例如,eas build --platform ios --message "Some message"。该消息会显示在 EAS 控制面板上。当你想向团队说明构建的目的时,这非常有用。
🌐 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 EAS 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:
- 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 开发者会员才能在 Google Play 商店分发应用。
你可以使用 EAS Build 构建并签署你的应用,但除非你拥有会员资格(一次性 25 美元费用),否则无法将其上传到 Google Play 商店。
🌐 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 开发者计划才能为 Apple App Store 构建应用。
如果你打算使用 EAS Build 为 Apple App Store 创建生产版本,你需要拥有一个 $99 美元的 Apple 开发者计划 会员账户。
🌐 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 服务器上。 - 如果你想手动生成你的密钥库,请参阅 手动 Android 凭据指南 获取更多信息。
iOS 应用签名凭证
🌐 iOS app signing credentials
- 如果你尚未生成配置文件和/或分发证书,请使用 EAS CLI 登录你的 Apple 开发者账户并按照提示操作。
- 如果你想手动生成你的凭证,请参阅手动 iOS 凭证指南了解更多信息。
等待构建完成
🌐 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:
- 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.
自动创建构建
🌐 Create builds automatically
你可以使用 EAS Workflows 在对特定分支的提交上自动创建构建。首先,你需要 配置你的项目,在项目根目录下添加一个名为 .eas/workflows/create-builds.yml 的文件,然后添加以下工作流配置:
🌐 You can automatically create builds on commits to specific branches with EAS Workflows. First, you'll need to configure your project, add a file named .eas/workflows/create-builds.yml at the root of your project, then add the following workflow configuration:
name: Create builds on: push: branches: ['main'] jobs: build_android: name: Build Android app type: build params: platform: android profile: production build_ios: name: Build iOS app type: build params: platform: ios profile: production
上述工作流程将在每次提交到你项目的 main 分支时创建 Android 和 iOS 构建。你也可以使用以下 EAS CLI 命令手动运行此工作流程:
🌐 The workflow above will create Android and iOS builds on every commit to your project's main branch. You can also run this workflow manually with the following EAS CLI command:
- eas workflow:run create-builds.yml通过工作流示例指南了解更多常见模式。
🌐 Learn more about common patterns with the workflows examples guide.
本地发布构建
🌐 Release builds locally
要在本地创建发布(也称为生产)版本,请参阅以下 React Native 指南,以获取有关 Android 和 iOS 所需步骤的更多信息。
🌐 To create a release (also known as production) build locally, see the following React Native guides for more information on the necessary steps for Android and iOS.
这些指南假设你的项目包含 android 和/或 ios 目录,这些目录中含有相应的原生项目。如果你使用 Continuous Native Generation,则需要在按照指南操作之前运行 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。
学习如何通过手动执行必要步骤将应用发布到 Google Play 商店。
学习如何通过手动执行必要步骤将应用发布到苹果 App Store。
下一步
🌐 Next step
了解将应用提交到应用商店的最佳实践。