在本地创建生产版本
了解如何在本地为你的 Expo 应用创建生产版本。
要在本地创建应用的生产版本(也称为发布版本),你需要在计算机上执行单独的步骤并使用创建任何原生应用所需的工具。本指南提供了 Android 和 iOS 的必要步骤。
¥To create your app's production build (also known as release build) locally, you need to follow separate steps on your computer and use the tools required to create any native app. This guide provides the necessary steps for Android and iOS.
安卓
¥Android
在本地为 Android 创建生产版本需要使用 上传密钥 对其进行签名并生成 Android 应用包 (.aab)。请按照以下步骤操作:
¥Creating a production build locally for Android requires signing it with an upload key and generating an Android Application Bundle (.aab). Follow the steps below:
先决条件
¥Prerequisites
-
OpenJDK 发行版 安装以访问
keytool
命令¥OpenJDK distribution installed to access the
keytool
command -
android 目录已生成。如果你使用的是 CNG,则运行
npx expo prebuild
来生成它。¥android directory generated. If you are using CNG, then run
npx expo prebuild
to generate it.
1
Create an upload key
Already created a build with EAS Build? Download your credentials and skip to the next step.
If you've already created a build with EAS Build, follow the steps below to download the credentials, which contains the upload key and its password, key alias, and key password:
- In your terminal, run
eas credentials -p android
and select the build profile. - Select credentials.json > Download credentials from EAS to credentials.json.
- Move the downloaded keystore.jks file to the android/app directory.
- Copy the values for the upload keystore password, key alias, and key password from the credentials.json as you will need them in the next step.
Inside your Expo project directory, run the following keytool
command to create an upload key:
!!!IG3!!!
After running this command, you will be prompted to enter a password for the keystore. This password will protect the upload key. Remember the password you enter here, as you'll need it in the next step.
This command also generates the keystore file named my-upload-key.keystore in your project directory. Move it to the android/app directory.
If you commit the android directory to a version control system like Git, don't commit this keystore file. It contains your upload key and should be kept private.
2
Update gradle variables
Open android/gradle.properties file and add the following gradle variables at the end of the file. Replace the *****
with the correct keystore and key password that you provided in the previous step.
These variables contain information about your upload key:
!!!IG0!!!
If you commit the android directory to a version control system like Git, don't commit the above information. Instead, create a ~/.gradle/gradle.properties file on your computer and add the above variables to this file.
3
4
5
iOS
To create an iOS production build locally for Apple App Store, you need to use Xcode which handles the signing and submission process via App Store Connect.
Prerequisites
- Paid Apple Developer membership
- Xcode installed on your computer
- ios directory generated. If you are using CNG, then run
npx expo prebuild
to generate it.
1
Open iOS workspace in Xcode
Inside your Expo project directory, run the following command to open your-project.xcworkspace
in Xcode:
!!!IG1!!!
After opening the iOS project in Xcode:
- From the sidebar on the left, select your app's workspace.
- Go to Signing & Capabilities and select All or Release.
- Under Signing > Team, ensure your Apple Developer team is selected. Xcode will generate an automatically managed Provisioning Profile and Signing Certificate.
2
3
4
App submission using App Store Connect
Once the build is complete, you can distribute your app to TestFlight or submit it to the App Store using App Store Connect:
- From the menu bar, open Product > Archive.
- Under Archives, click Distribute App from the right sidebar.
- Click App Store Connect and follow the prompts shown in the window. This step will create an app store record and upload your app to the App Store.
- Now you can go to your App Store Connect account, select your app under Apps, and submit it for testing using TestFlight or prepare it for final release by following the steps in the App Store Connect dashboard.