自动 OTA 或本机
Wire bundle releaseType 将 GitHub Actions 或 GitLab 导入到 CI 中,以便 CI 检测实时更新 vs Capgo Build。
复制一个包含安装步骤和本插件的完整Markdown指南的设置提示.
一个Capgo实时更新将替换您的应用的 JavaScript包 立即生效,但无法改变 原生 part of your app — the Capacitor/Cordova plugins, native dependencies, and native project configuration that are compiled into the installed binary. When a new bundle expects native code that the installed binary doesn’t have, the bundle is 原生不兼容: Capgo仍然可以传递它,但在仍在运行旧版原生构建的设备上,它可能会崩溃或不正常工作。
This page explains how Capgo detects native compatibility, what an incompatible update means for your users, and how to ship native changes safely.
Capgo can send files from your generated web build folder. If the change only affects HTML, CSS, JavaScript, assets, or pure-JavaScript packages bundled into that output, ship it as a live update.
使用原生应用发布时,更新变更时 capacitor.config.ts插件配置存储在Capacitor配置中,原生插件或依赖项,Capacitor自身,或iOS/Android项目文件。实用检查:如果变更必须更新原生项目通过 npx cap sync 或 npx cap copy 在安装设备上使用它之前,视为原生。
| 变更 | 与CapgoOTA一起发布? | 为什么 |
|---|---|---|
| HTML、CSS、应用JavaScript、图像、字体和其他Web构建资产 | 是 | 它们在运行时从Web包中加载。 |
| 纯JavaScript包更改打包到您的Web输出中 | 是 | The generated JavaScript is part of the web bundle. |
capacitor.config.ts 更改 | No | Capacitor 配置在构建时间读入到原生应用中。 |
| 添加、删除或升级 Capacitor/Cordova 插件 | No | 安装的原生二进制文件必须包含匹配的原生 code。 |
| iOS 或 Android 项目文件更改 | No | 现有用户需要从商店获取新的二进制文件。 |
Capgo 为每个混合运行时提供专用更新客户端:
| 插件 | 使用时 |
|---|---|
@capgo/capacitor-updater | Capacitor iOS/Android 应用 |
@capgo/cordova-updater | Cordova iOS 7+ / Android 13+ 应用 |
@capgo/electron-updater | Electron 桌面应用 |
原生兼容性检查始终适用于客户端插件 — 它们将捆绑的原生依赖项与安装的二进制文件进行比较。
每个 Capacitor 应用都有两个层次:
实时更新仅更换 JavaScript 层。如果该新 JavaScript 调用原生插件或 API,但未编译到已安装的二进制文件中,则在运行时会出现调用失败的情况 —— 这可能会导致应用程序崩溃或静默地破坏一个功能。简而言之: Capgo 无法更新原生 code,因此运行旧原生构建的设备无法安全地运行针对新原生 code 构建的包。
当您上传包或手动运行检查时,Capgo 将比较 本地项目中的原生包 (您的 Capacitor/Cordova 插件及其版本)与包 当前在渠道上记录的原生包:
bunx @capgo/cli@latest bundle compatibility com.example.app --channel productionCLI 打印出每个原生包的本地版本、该版本在渠道中的版本和状态:
Package Local Remote Status@capacitor/core 6.1.2 6.1.2 ✅@capacitor/share 6.0.0 6.0.0 ✅@capacitor/camera 6.1.0 — ❌ not in the live bundle对于管道, bundle releaseType 将检查压缩为一个单词:
bunx @capgo/cli@latest bundle releaseType com.example.app --channel production# → OTA safe to ship as a live update# → native needs a new app-store build将发布管道门控在此:在它打印时发送一个实时更新, OTA并在它打印时触发一个原生构建, native.
在仍在运行的原生二进制文件的设备上,缺失的原生__CAPGO_KEEP_0__可能会导致程序崩溃或功能异常 — 即使更新下载并应用成功。这是为什么即使是实时更新可以实时发布并仍然会破坏现有用户的应用,以及为什么__CAPGO_KEEP_1__可以在不兼容的包发布时警告你的原因。 __CAPGO_KEEP_0__的, the missing native code can cause crashes or broken features — even though the update downloaded and applied “successfully.” This is why a live update can be live and delivered yet still break the app for existing users, and why Capgo can warn you when an incompatible bundle goes live.
可以捕获在Capgo运行之前抛出的JavaScript错误,但这并不是代替发布兼容的原生Capgo的方法 — 一旦出现原生崩溃或崩溃,后果就无法避免了。 安全地发布原生更新 安全地发布原生更新 notifyAppReady() runs, but it isn’t a substitute for shipping compatible native code — a mismatch that crashes later, or crashes natively, can slip past it.
When a bundle needs new native code, build and submit a new binary to the App Store / Play Store (or rebuild with Capgo Cloud Build). Once users update the binary, the bundle’s native dependencies line up and the live update runs correctly.
如果某个频道上已经发布了不兼容的包,恢复到上一个兼容的版本,直到用户安装了本地包为止。请参阅 回滚.
两个互补的守卫,实际上都检查了您的本地包:
CI 中的上传失败 — --fail-on-incompatible
将标志添加到您的 bundle upload 步骤。如果包的本地包不匹配频道的当前发布版本,上传 将以非零退出码失败,并且不会发布任何内容 — 因此您的管道会阻止您静默发布一个无法立即生效的 OTA 更新,直到用户安装了本地包:
bunx @capgo/cli@latest bundle upload --channel production --fail-on-incompatible兼容上传 — 和检查无法运行的情况(新频道或无远程元数据) — 将保持不变。 在交互式终端中,它提供了 Capgo Builder 原生构建流程;拒绝将导致失败。 (无法与 --ignore-metadata-check.)
Gate 原生版本的交付 — metadata + --auto-min-update-version
当您 将原生构建和捆绑包一起发送时,请将频道放在 策略上并上传 metadata 。 __CAPGO_KEEP_0__ 在每次上传时运行兼容性检查,并在捆绑包需要新的原生 __CAPGO_KEEP_1__ 时,升高更新阈值,以便尚未安装匹配原生构建的设备不会接收到它: --auto-min-update-version. Capgo runs the compatibility check on every upload and, when a bundle needs new native code, raises the update floor so devices that haven’t installed the matching native build don’t receive it:
# one-time: switch the channel to the metadata strategybunx @capgo/cli@latest channel set production com.example.app --disable-auto-update metadata
# from then on, Capgo sets the floor automatically on every uploadbunx @capgo/cli@latest bundle upload --channel production --auto-min-update-version参见 版本目标 了解所有目标选项的详细信息。
自动 OTA 或本机
Wire bundle releaseType 将 GitHub Actions 或 GitLab 导入到 CI 中,以便 CI 检测实时更新 vs Capgo Build。
版本目标
仅使用通道、语义版本规则和元数据策略来分发兼容的包。
回滚
如果发布不兼容的包,则将通道恢复到最后一个兼容的构建。
更新类型
了解如何将应用时间、延迟条件和版本阻塞一起使用。
CLI: 包
包兼容性、发布类型和上传选项的参考。
如果您正在使用 原生兼容性 来安全地保持实时更新,连接它与 版本目标 来通过原生版本路由捆绑包, 回滚 来恢复当不兼容的捆绑包发布时, 更新类型 来了解通道版本阻塞,和 Capgo CLI捆绑包引用 用于兼容性和releaseType命令。