使用 eas.json 配置 EAS 提交

了解如何使用 eas.json 配置 EAS 提交项目。


eas.json 是 EAS CLI 和服务的配置文件。当你的项目第一次运行 eas build:configure 命令 时,它会生成,并位于项目根目录下与 package.json 同级的位置。尽管 eas.json 并非使用 EAS Submit 的必需文件,但如果你需要在不同配置之间切换,它会让你的操作更加方便。

生产概况

🌐 Production profile

在不指定配置文件名称的情况下运行 eas submit 将使用已在 eas.json 中定义的 production 配置文件来配置提交。如果 production 配置文件中没有值,EAS CLI 会提示你以交互方式提供这些值。

🌐 Running eas submit without specifying a profile name will use the production profile if it is already defined in eas.json to configure the submission. If no values exist in the production profile, EAS CLI will prompt you to provide the values interactively.

下面显示的 production 配置文件是运行 Android 和 iOS 提交所需的,在 CI/CD 流程中使用,例如通过 EAS Workflows

🌐 The production profile shown below is required to run Android and iOS submissions in a CI/CD process, like with EAS Workflows:

eas.json
{ "cli": { "version": ">= 0.34.0" }, "submit": { "production": { "android": { "track": "internal" }, "ios": { "ascAppId": "your-app-store-connect-app-id" } } } }

了解更多有关你可以通过 Android 特定选项iOS 特定选项 设置的值的信息。你还可以了解如何提交到 Apple App StoreGoogle Play Store

🌐 Learn more about the values you can set with the Android specific options and the iOS specific options. You can also learn how to submit to the Apple App Store and the Google Play Store.

多个配置文件

🌐 Multiple profiles

submit 下的 JSON 对象可以包含多个提交配置文件。submit 下的每个配置文件可以有任意名称,如下面的示例所示:

🌐 The JSON object under submit can contain multiple submit profiles. Each profile under submit can have an arbitrary name as shown in the example below:

eas.json
{ "cli": { "version": "SEMVER_RANGE", "requireCommit": boolean }, "build": { // EAS Build configuration %%placeholder-start%%... %%placeholder-end%% }, "submit": { "SUBMIT_PROFILE_NAME_1": { "android": { ...ANDROID_OPTIONS }, "ios": { ...IOS_OPTIONS } }, "SUBMIT_PROFILE_NAME_2": { "extends": "SUBMIT_PROFILE_NAME_1", "android": { ...ANDROID_OPTIONS } }, %%placeholder-start%%... %%placeholder-end%% } }

当你选择一个用于提交的构建时,它会选择用于所选构建的配置文件。如果该配置文件不存在,它会选择默认的 production 配置文件。

🌐 When you select a build for submission, it chooses the profile that is used for the selected build. If the profile does not exist, it selects the default production profile.

你也可以使用 EAS CLI 通过指定参数来选择另一个 submit 配置文件,例如:

🌐 You can also use EAS CLI to pick up another submit profile by specifying it with a parameter, for example:

Terminal
# Replace the <profile-name> with a submit profile from the eas.json
eas submit --platform ios --profile <profile-name>

submit 配置文件之间共享配置

🌐 Share configuration between submit profiles

submit 配置文件可以使用 extends 键扩展另一个配置文件。

🌐 A submit profile can extend another profile using the extends key.

例如,在 preview 配置文件中,你可能有 "extends": "production"。这使得 preview 配置文件继承 production 配置文件的配置。

🌐 For example, in the preview profile you may have "extends": "production". This makes the preview profile inherit the configuration of the production profile.

只要避免产生循环依赖,你就可以将配置文件扩展链接至 5 个深度。

🌐 You can keep chaining profile extensions up to the depth of 5 as long as you avoid making circular dependencies.

下一步

🌐 Next step

EAS 提交架构参考

了解可用于 EAS Submit 的属性,以便在项目中配置并覆盖它们的默认行为。