跳转到正文

🔹 Build

🏗️ 通过 Capgo Cloud 管理 iOS/Android Native Build。

所有 Capgo 方案均支持云端 Native Build。构建凭据绝不会存储在 Capgo 服务器上:它们仅用于构建过程,完成后即被删除。构建输出可以选择上传,并提供有时效性的下载链接。

终端窗口
npx @capgo/cli build credentials save --appId YOUR_APP_ID --platform ios
npx @capgo/cli build credentials save --appId YOUR_APP_ID --platform android

传入 --output-record 以持久化下载 URL 和 QR code,然后使用 build last-output 来读取它:

终端窗口
npx @capgo/cli build request APP_ID --platform android --output-upload --output-record /tmp/build.json
npx @capgo/cli build last-output --path /tmp/build.json --field outputUrl
终端窗口
npx @capgo/cli@latest build needed

🧭 如果需要 Native Build,则打印 “yes” 并以 code 1 退出;否则打印 “no” 并以 code 0 退出。命令失败则以 code 2 退出。

示例:

终端窗口
npx @capgo/cli@latest build needed com.example.app --channel production --verbose

选项:

参数类型描述
-astringAPI 用于关联您的账户的密钥
-cstring用于对比的 Channel。默认为 CapacitorUpdater.defaultChannel 或公共默认 Channel
—package-jsonstringMonorepo 中 package.json 文件的路径(以逗号分隔)
—node-modulesstringMonorepo 中 node_modules 目录的路径(以逗号分隔)
—verboseboolean启用详细日志输出
—supa-hoststring自定义 Supabase host URL(用于自托管或 Capgo 开发)
—supa-anonstring自定义 Supabase anon key(用于自托管)

别名: onboarding

终端窗口
npx @capgo/cli@latest build init

以交互方式设置 build 凭据(iOS:自动配置证书和描述文件;Android:keystore + Google OAuth,用于配置 GCP 服务账号并发送 Play Console 邀请)

选项:

参数类型描述
-astringAPI 用于关联您的账户的密钥
-pstring要进行 onboarding 的平台 (ios 或 android)。如果省略,当仅存在一个原生文件夹时会自动检测;否则会进行 prompt。
—supa-hoststring自定义 Supabase host URL(用于自托管或 Capgo 开发)
—no-analyticsboolean在此次运行中禁用 build onboarding analytics 和 terminal replay
终端窗口
npx @capgo/cli@latest build request

向 Capgo Cloud 请求 Native Build。 该命令会将您的项目目录压缩并 upload 到 Capgo 进行构建。 构建完成后将直接发送至应用商店。 凭据绝不会存储在 Capgo 服务器上;构建完成后即会被删除。请在请求构建前保存好凭据:

终端窗口
npx @capgo/cli build credentials save --appId APP_ID --platform ios

示例:

终端窗口
npx @capgo/cli@latest build request com.example.app --platform ios --path .

选项:

参数类型描述
—pathstring要构建的项目目录路径(默认:当前目录)
—node-modulesstringMonorepo 模式下 node_modules 的路径(以逗号分隔)
—platformstring目标平台:ios 或 android(必填)
—build-modestring构建模式:debug 或 release(默认:release)
—build-certificate-base64stringiOS:Base64 编码的 .p12 证书
—p12-passwordstringiOS: P12 证书密码(若证书无密码则可选)
—apple-idstringiOS: 用于上传 App-specific password 的 Apple ID 邮箱(可作为 App Store Connect API key 的替代方案)
—apple-app-specific-passwordstringiOS: 用于 TestFlight 上传的 App-specific password (xxxx-xxxx-xxxx-xxxx)
—apple-app-idstringiOS: App Store Connect 数字 App ID(需配合 —apple-id 和 —apple-app-specific-password 使用)
—apple-key-idstringiOS: App Store Connect API Key ID
—apple-issuer-idstringiOS:App Store Connect Issuer ID
—apple-key-contentstringiOS: Base64 编码的 App Store Connect API 密钥 (.p8)
—app-store-connect-team-idstringiOS:App Store Connect Team ID
—ios-schemestringiOS: 用于构建的 Xcode scheme (默认值: App)
—ios-targetstringiOS: 用于读取构建设置的 Xcode target (默认值: 与 scheme 相同)
—xcode-versionstringiOS: 在指定 Xcode 版本的机器上进行构建 (例如 26, 26.0.1, 27)。主版本号可匹配任何次版本号。默认值: 任意机器。优先级: CLI > 环境变量 (CAPGO_IOS_XCODE_VERSION) > 已保存的凭据
—ios-distributionstringiOS: 分发模式
—ios-provisioning-profilestringiOS: Provisioning profile 路径或 bundleId=path 映射 (可重复使用)
—android-keystore-filestringAndroid: Base64 编码的 keystore 文件
—keystore-key-aliasstringAndroid:Keystore 密钥别名
—keystore-key-passwordstringAndroid: Keystore key 密码
—keystore-store-passwordstringAndroid: Keystore store 密码
—play-config-jsonstringAndroid: Base64 编码的 Google Play 服务账号 JSON
—android-flavorstringAndroid: 要构建的 Product flavor(例如 production)。如果项目包含多个 flavor,则此项必填。
—android-trackstringAndroid: 本次上传对应的 Google Play track(internal, alpha, beta, production)。若未指定 —submit-to-store-review,默认值为 internal;若指定了 —submit-to-store-review 且未设置 track,则为 production。优先级:CLI > env > 已保存的凭据
—android-release-statusstringAndroid: Google Play 发布状态(draft, completed, inProgress, halted)。若未指定 —submit-to-store-review,默认值为 draft;若指定了 —submit-to-store-review 且未设置 status,则为 completed。优先级:CLI > env > 已保存的凭据
—in-app-update-prioritystringAndroid: 本次发布的 Google Play 应用内更新优先级(整数 0–5;数值越高越紧急)。详见 https://developer.android.com/guide/playcore/in-app-updates。优先级:CLI > env > 已保存的凭据
—no-playstore-uploadboolean跳过本次构建的 Play Store 上传(会将已保存的 Play 配置置空)。需要配合 —output-upload 使用。
—submit-to-store-reviewboolean上传完成后,将商店版本提交审核,而不是将其保持为草稿或未激活状态。在 Android 上,这默认提交到 production 轨道且 release_status 为 completed(可通过 —android-track / PLAY_STORE_TRACK 和 —android-release-status / PLAY_STORE_RELEASE_STATUS 进行覆盖)。在 iOS 上,这会将处理好的 TestFlight build 提交至 App Store 审核。
—store-release-namestring商店发布名称/版本标签。Android 会将其作为 Google Play 的 version_name 发送;iOS 在创建或复用可编辑版本时,将其作为 App Store 版本号使用。
—store-release-notesstring默认的商店发布说明。Android 将其作为 Play 的更新日志;iOS 则将其作为 App Store “新功能”文本的备选内容。
—store-release-notes-localestring本地化的商店发布说明(可多次使用),例如 —store-release-notes-locale en-US=“Bug fixes” —store-release-notes-locale fr-FR=“Corrections”。
—ios-testflight-groupsstringiOS:可选参数,使用逗号分隔的 TestFlight 外部测试组名称或 ID,用于外部 Beta 测试分发。
—ios-automatic-releasebooleaniOS:在 Apple 审核通过后自动发布 App Store 版本。默认设置为手动发布。
—no-ios-automatic-releasebooleaniOS:Apple 审核通过后,让 App Store 版本保持待手动发布状态。
—output-uploadboolean仅针对本次 build 覆盖输出上传行为(启用)。优先级:CLI > 环境变量 > 已保存的凭据
—no-output-uploadboolean仅针对本次 build 覆盖输出上传行为(禁用)。优先级:CLI > 环境变量 > 已保存的凭据
—output-retentionstring仅针对本次 build 覆盖输出链接的 TTL(1h 至 7d)。示例:1h、6h、2d。优先级:CLI > 环境变量 > 已保存的凭据
—output-recordstringbuild 成功后,将 JSON 记录(jobId、status、outputUrl、qrCodeAscii、qrCodePngPath、finishedAt)写入指定路径。同时会在该路径旁写入一个 PNG QR code,并带有 .qr.png 后缀。读回字段请使用 build last-output.
—no-cacheboolean跳过构建缓存恢复 以及 本次构建不保存新的缓存条目。每个 App 默认启用构建缓存。
—cache-keystring按环境、分支或 Android flavor 划分构建缓存(例如 prod, staging)。省略则每个 App 共用一个默认缓存。
—no-skip-build-number-bumpboolean覆盖已保存的凭据,仅本次构建重新启用 build number 自动递增。
—skip-marketing-version-bumpboolean当 App 已发布时,跳过自动递增营销版本号(CFBundleShortVersionString / versionName)。
—sync-ios-versionbooleaniOS:上传项目前,从 package.json 同步 Xcode 的 MARKETING_VERSION。
—ai-analyticsboolean构建失败时,将 logs 发送至 Capgo AI 进行诊断。在交互式终端中,此选项会跳过前置确认;在 CI 环境中,则会自动上传并将分析结果打印到 stderr。
—no-prescanboolean跳过自动构建前扫描 (pre-build scan)
—prescan-ignore-fatalboolean运行构建前扫描,但即使出错也不阻塞构建(仅报告)
—prescan-skipstring通过 ID 跳过特定的 prescan 检查(可多次使用或用逗号分隔)。其他检查仍会运行。
—prescan-warnstring通过 ID 将特定的 prescan 检查降级为警告(可多次使用或用逗号分隔)。检查仍会运行。
—fail-on-warningsboolean将 prescan 警告视为致命错误
—send-logs-to-supportboolean若 CI/CD 构建失败,自动将构建日志上传至 Capgo 支持团队(无需通过邮件)。Capgo 支持团队会收到通知并随后通过邮件跟进。此功能与 —ai-analytics 叠加使用。
—send-logsboolean—send-logs-to-support 的弃用别名
-astringAPI 用于关联您的账户的密钥
—supa-hoststring自定义 Supabase host URL(用于自托管或 Capgo 开发)
—supa-anonstring自定义 Supabase anon key(用于自托管)
—verboseboolean启用详细日志输出

构建缓存: 默认情况下,Capgo 会按应用恢复并保存编译后的 Native 产物(CocoaPods、Gradle 及相关输出)。使用 --cache-key 可将 RC 和生产环境缓存分开;使用 --no-cache 进行一次性全新构建。API 集成可以通过 cache_key 或 cache_enabled: false 在构建请求的 payload 中传递参数。详见 构建缓存 以及 故障排除:缓存恢复错误.

终端窗口
npx @capgo/cli@latest build sync-ios-version

根据 package.json 同步本地 iOS Xcode 的 MARKETING_VERSION。

示例:

终端窗口
npx @capgo/cli@latest build sync-ios-version --path .

选项:

参数类型描述
—pathstring项目目录路径 (默认:当前目录)
—checkboolean仅进行检查;若 MARKETING_VERSION 不同步则返回非零退出码
终端窗口
npx @capgo/cli@latest build prescan

Scan your project and saved credentials for problems that would fail a cloud build — before uploading anything. Checks credentials (expiry, passwords, profile pairing), project state (cap sync, node_modules layout), and platform config. Runs automatically inside build request; 此命令可独立运行(例如在 CI 中)。 请参阅 预扫描检查 以获取完整的检查目录以及如何 --skip / --warn 单个规则。

选项:

参数类型描述
—platformstring目标平台:ios 或 android(必填)
—pathstring项目目录路径(默认:当前目录)
-astringAPI 用于关联您的账户的密钥
—android-flavorstringAndroid:构建时使用的 product flavor
—ios-diststringiOS:用于校验的 distribution mode
—jsonboolean输出机器可读的 JSON 报告
—fail-on-warningsboolean发现警告时以非零状态码退出 (适用于 CI)
—ignore-fatalboolean诊断模式:报告所有问题但始终以状态码 0 退出
—skipstring通过 ID 跳过特定的检查 (可多次使用或用逗号分隔)
—warnstring通过 ID 将特定检查降级为警告 (可多次使用或用逗号分隔)
—verboseboolean启用详细日志输出
—supa-hoststring自定义 Supabase host URL(用于自托管或 Capgo 开发)
—supa-anonstring自定义 Supabase anon key(用于自托管)
终端窗口
npx @capgo/cli@latest build last-output

读取上一次写入的构建输出记录 build request --output-record. 默认输出完整 JSON,使用 —field 输出单个字段,或使用 —qr 输出 ASCII QR code。在 CI 中很方便,可抓取下载 URL 或 QR 码,回帖到 PR 或 issue。 示例: npx @capgo/cli build last-output —path /tmp/build.json npx @capgo/cli build last-output —path /tmp/build.json —field outputUrl npx @capgo/cli build last-output —path /tmp/build.json —qr

选项:

参数类型描述
—pathstring由 —output-record 写入的 JSON 记录路径(必填)
—fieldstring打印单个字段(可选值:jobId, appId, platform, buildMode, status, outputUrl, qrCodeAscii, qrCodePngPath, finishedAt, schemaVersion)
—qrboolean打印渲染后的 ASCII QR code(—field qrCodeAscii 的快捷方式)

管理存储在本机的 build 凭据。 🔒 安全:

别名: asc-key

终端窗口
npx @capgo/cli@latest build credentials apple-key

通过 macOS 引导助手创建 App Store Connect 团队 API 密钥(仅限 macOS)。 它会打开一个原生窗口,在嵌入式浏览器中引导你完成 Apple App Store Connect 的 UI 操作,自动获取 Issuer ID + Key ID,拦截一次性的 .p8 文件,向 Apple 进行验证,并将其保存至 ~/.appstoreconnect/private_keys。 进度统计数据会发送至 Capgo 进行分析(可通过 CAPGO_DISABLE_TELEMETRY 禁用)。 npx @capgo/cli build credentials apple-key —appId com.example.app

示例:

终端窗口
Example:

选项:

参数类型描述
-astringAPI 用于关联您的账户的密钥
—appIdstring将捕获的密钥保存到此应用的 iOS 构建凭据中
—localboolean将凭据保存至项目专属的 .capgo-credentials.json,而非全局文件
—jsonboolean以 JSON 格式打印获取到的 Key ID / Issuer ID / .p8 路径
终端窗口
npx @capgo/cli@latest build credentials save

在本地保存 iOS 或 Android 的构建凭据。 凭据存储在:

  • ~/.capgo-credentials/credentials.json (默认,全局)
  • 项目根目录下的 .capgo-credentials.json (使用 —local 标志) ⚠️ 构建前必做:在请求构建之前,必须先保存凭据。 🔒 这些凭据绝不会永久存储在 Capgo 服务器上。 构建完成后会立即删除。 📚 配置指南: iOS: https://capgo.app/docs/cli/cloud-build/ios/ Android: https://capgo.app/docs/cli/cloud-build/android/ npx @capgo/cli build credentials save —platform ios
    —certificate ./cert.p12 —p12-password “password”
    —ios-provisioning-profile ./profile.mobileprovision
    —apple-key ./AuthKey.p8 —apple-key-id “KEY123”
    —apple-issuer-id “issuer-uuid” —apple-team-id “team-id” 多 Target 示例 (app + widget extension): npx @capgo/cli build credentials save —platform ios
    —ios-provisioning-profile ./App.mobileprovision
    —ios-provisioning-profile com.example.widget=./Widget.mobileprovision
    … npx @capgo/cli build credentials save —平台 android
    —keystore ./release.keystore —keystore-alias “my-key”
    —keystore-key-password “key-pass”
    —play-config ./service-account.json 本地存储 (按项目): npx @capgo/cli build credentials save —local —platform ios …

示例:

终端窗口
iOS Example:

选项:

参数类型描述
—appIdstringApp ID (例如: com.example.app) (必填)
—platformstringPlatform: ios 或 android (必填)
—certificatestringiOS: .p12 证书文件路径
—ios-provisioning-profilestringiOS: Provisioning profile 路径或 bundleId=path (可重复)
—p12-passwordstringiOS: 证书密码 (若证书无密码则可选)
—apple-keystringiOS: App Store Connect API .p8 密钥路径
—apple-key-idstringiOS: App Store Connect API Key ID
—apple-issuer-idstringiOS:App Store Connect Issuer ID
—apple-team-idstringiOS:App Store Connect Team ID
—ios-distributionstringiOS: 发行模式
—apple-idstringiOS: 用于上传 App 专用密码的 Apple ID 邮箱 (作为 App Store Connect API 密钥的替代方案)
—apple-app-specific-passwordstringiOS: 用于 TestFlight 上传的 App 专用密码 (xxxx-xxxx-xxxx-xxxx)
—apple-app-idstringiOS: App Store Connect App ID 数字 ID (需配合 —apple-id 和 —apple-app-specific-password 使用)
—keystorestringAndroid: Keystore 文件路径 (.keystore 或 .jks)
—keystore-aliasstringAndroid: Keystore 密钥别名
—keystore-key-passwordstringAndroid: Keystore 密钥密码
—keystore-store-passwordstringAndroid: Keystore 存储库密码
—play-configstringAndroid: Play Store 服务账号 JSON 路径
—android-flavorstringAndroid: 要构建的 Product flavor(例如 production)。如果项目包含多个 flavor,则此项必填。
—in-app-update-prioritystringAndroid: Google Play 应用内更新优先级(整数 0–5;数值越高越紧急)。若省略则保持 Play Store 原有值不变。
—localboolean保存到项目根目录下的 .capgo-credentials.json,而不是全局的 ~/.capgo-credentials/
—output-uploadboolean将构建产物 (IPA/APK/AAB) 上传至 Capgo 存储并打印下载链接
—no-output-uploadboolean不要将构建产物 (IPA/APK/AAB) 上传至 Capgo 存储
—output-retentionstring输出链接 TTL:1h 至 7d(默认:1h)。示例:1h、6h、2d
—skip-build-number-bumpboolean在后续构建中跳过 build number/version code 的自动递增
—no-skip-build-number-bumpboolean重新启用 build number 自动递增(默认行为)
—skip-marketing-version-bumpboolean当应用已发布时,在后续构建中跳过自动营销版本号更新
—no-skip-marketing-version-bumpboolean重新启用自动营销版本号更新(默认行为)
终端窗口
npx @capgo/cli@latest build credentials list

列出已保存的构建凭据(密码已脱敏)。 显示当前保存的凭据(包括全局和本地凭据)。 示例: npx @capgo/cli build credentials list # 列出所有应用 npx @capgo/cli build credentials list —appId com.example.app # 列出特定应用

选项:

参数类型描述
—appIdstring要列出的 App ID(可选,若省略则列出所有)
—localboolean仅列出本地 .capgo-credentials.json 中的凭据
终端窗口
npx @capgo/cli@latest build credentials clear

清除已保存的 build 凭据。 从存储中移除凭据。 使用 —appId 和 —platform 来指定特定的凭据。 示例: npx @capgo/cli build credentials clear # 清除所有 App(全局) npx @capgo/cli build credentials clear —local # 清除本地凭据 npx @capgo/cli build credentials clear —appId com.example.app —platform ios

选项:

参数类型描述
—appIdstring要清除的 App ID(可选,若省略则清除所有 App)
—platformstring要清除的平台:ios 或 android(可选,若省略则清除所有平台)
—localboolean从本地 .capgo-credentials.json 而非全局配置中清除
终端窗口
npx @capgo/cli@latest build credentials update

无需重新提供所有信息即可更新特定凭据。 仅需提供想要更改的字段即可更新现有凭据。 平台将根据你提供的选项自动检测。 示例: npx @capgo/cli build credentials update —ios-provisioning-profile ./new-profile.mobileprovision npx @capgo/cli build credentials update —local —keystore ./new-keystore.jks

选项:

参数类型描述
—appIdstringApp ID(若省略,则从 capacitor.config 自动检测)
—platformstring平台:ios 或 android(根据选项自动检测)
—localboolean更新本地 .capgo-credentials.json 而非全局文件
—certificatestringP12 证书文件的路径
—ios-provisioning-profilestringProvisioning profile 路径或 bundleId=path(可重复使用,默认采用增量合并方式)
—overwrite-ios-provisioning-mapboolean替换整个 provisioning map 而不是进行合并(默认:merge)
—p12-passwordstringP12 证书密码
—apple-keystringApp Store Connect API 密钥路径 (.p8 文件)
—apple-key-idstringApp Store Connect API Key ID
—apple-issuer-idstringApp Store Connect Issuer ID
—apple-team-idstringApp Store Connect 团队 ID
—apple-idstringiOS: 用于上传 app-specific password 的 Apple ID 邮箱(作为 App Store Connect API 密钥的替代方案)
—apple-app-specific-passwordstringiOS: 用于 TestFlight 上传的 App-specific password (xxxx-xxxx-xxxx-xxxx)
—apple-app-idstringiOS: App Store Connect 的数字 App ID(需配合 —apple-id 和 —apple-app-specific-password 使用)
—ios-distributionstringiOS: 发行模式
—keystorestringKeystore 文件路径 (.keystore 或 .jks)
—keystore-aliasstringKeystore 密钥别名
—keystore-key-passwordstringKeystore 密钥密码
—keystore-store-passwordstringKeystore 存储库密码
—play-configstringGoogle Play 服务账号 JSON 文件的路径
—android-flavorstringAndroid: 要构建的 Product flavor(例如 production)。如果项目包含多个 flavor,则此项必填。
—in-app-update-prioritystringAndroid:后续发布的 Google Play 应用内更新优先级(整数 0–5;数值越高越紧急)。
—output-uploadboolean将构建产物 (IPA/APK/AAB) 上传至 Capgo 存储并打印下载链接
—no-output-uploadboolean不要将构建产物 (IPA/APK/AAB) 上传至 Capgo 存储
—output-retentionstring输出链接 TTL:1h 至 7d。示例:1h, 6h, 2d
—skip-build-number-bumpboolean在后续构建中跳过 build number/version code 的自动递增
—no-skip-build-number-bumpboolean重新启用 build number 自动递增(默认行为)
—skip-marketing-version-bumpboolean当 App 已发布时,跳过后续构建中自动递增 marketing version
—no-skip-marketing-version-bumpboolean重新启用自动营销版本号递增(默认行为)
终端窗口
npx @capgo/cli@latest build credentials manage

交互式管理已保存的构建凭据。 浏览存储的凭据、查看配置详情、导出适用于 CI/CD 的 .env 文件,或删除特定平台的凭据。复用了与以下相同的 TUI: capgo init。 示例: npx @capgo/cli build credentials manage npx @capgo/cli build credentials manage —appId com.example.app npx @capgo/cli build credentials manage —appId com.example.app —platform ios npx @capgo/cli build credentials manage —local

选项:

参数类型描述
—appIdstring要管理的 App ID(可选,若省略则会提示选择)
—platformstring要管理的平台:ios 或 android(可选,若省略则会提示选择)
—localboolean仅浏览本地的 .capgo-credentials.json
终端窗口
npx @capgo/cli@latest build credentials migrate

将旧版 provisioning profile 迁移至新的多目标格式。 将 BUILD_PROVISION_PROFILE_BASE64 转换为 CAPGO_IOS_PROVISIONING_MAP。 自动从您的 Xcode 项目中获取主 bundle ID。 npx @capgo/cli build credentials migrate —platform ios

示例:

终端窗口
Example:

选项:

参数类型描述
—appIdstringApp ID(若未提供,将从 capacitor.config 自动检测)
—platformstring平台(仅支持 ios)
—localboolean从本地 .capgo-credentials.json 迁移,而非全局配置