使用 eas.json 配置 EAS Submit
编辑页面
了解如何使用 eas.json 为 EAS Submit 配置你的项目。
For the complete documentation index, see llms.txt. Use this Use this file to discover all available pages.
eas.json 是 EAS CLI 和服务的配置文件。它会在你的项目中首次运行 eas build:configure 命令 时生成,并位于项目根目录中 package.json 的旁边。尽管使用 EAS Submit 并非必须提供 eas.json,但如果你需要在不同配置之间切换,它会让事情变得更轻松。
Production profile
如果运行 eas submit 时不指定 profile 名称,并且 eas.json 中已定义 production profile,则会使用 production profile 来配置提交。如果 production profile 中没有任何值,EAS CLI 会提示你以交互方式提供这些值。
下面展示的 production profile 是在 CI/CD 流程中运行 Android 和 iOS 提交所必需的,例如使用 EAS Workflows:
{ "cli": { "version": ">= 0.34.0" }, "submit": { "production": { "android": { "track": "internal" }, "ios": { "ascAppId": "your-app-store-connect-app-id" } } } }
了解更多关于你可以设置的值,请参阅 Android specific options 和 iOS specific options。你也可以了解如何提交到 Apple App Store 和 Google Play Store。
Multiple profiles
submit 下的 JSON 对象可以包含多个 submit profile。submit 下的每个 profile 都可以拥有任意名称,如下方示例所示:
{ "cli": { "version": "SEMVER_RANGE", "requireCommit": boolean }, "build": { // EAS Build 配置 %%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 配置文件。
你也可以通过指定参数来使用 EAS CLI 选择另一个 submit 配置文件,例如:
# 将 <profile-name> 替换为 eas.json 中的一个 submit 配置文件- eas submit --platform ios --profile <profile-name>在 submit 配置文件之间共享配置
submit 配置文件可以使用 extends 键扩展另一个配置文件。
例如,在 preview 配置文件中,你可能有 "extends": "production"。这会使 preview 配置文件继承 production 配置文件的配置。
只要避免创建循环依赖,你可以继续链式扩展配置文件,最多可达 5 层深度。
下一步
了解可用于 EAS Submit 的属性,以及如何在项目中配置它们并覆盖其默认行为。