开始使用
复制一个包含安装步骤和本插件的完整 Markdown 指南的配置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-patch`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/capacitor-patch/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
安装
标题:安装npm install @capgo/capacitor-patchnpx cap syncCapacitor 配置中选择补丁之前,包都是无效的。
选择补丁 ID
标题:选择补丁 ID列出所有已发货补丁:
npx capgo-capacitor-patch list --all然后添加您的应用程序需要的修补程序ID capacitor.config.ts:
import type { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = { appId: 'com.example.app', appName: 'Example', webDir: 'dist', plugins: { CapacitorPatch: { patches: ['upstream-pr-8418-android'], strict: true, }, },};
export default config;再次运行同步:
npx cap sync包修补程序在 sync 和 update. 本机项目修补程序在 sync 和 update.
dry-run 在应用之前
标题为“dry-run 在应用之前”使用 doctor __CAPGO_KEEP_0__
npx capgo-capacitor-patch doctor --phase package --strict使用 apply __CAPGO_KEEP_0__
npx capgo-capacitor-patch apply --phase package配置选项
配置选项| 选项 | 类型 | 默认 | 描述 |
|---|---|---|---|
recommended | boolean | false | 应用标记为推荐的补丁 Capgo |
patches | string[] | [] | 应用显式补丁 ID |
disabled | string[] | [] | 跳过选定的补丁 ID,即使它们被推荐 |
strict | boolean | false | 当选定的补丁不兼容或无法应用时抛出 |
CLI 命令
标题为“CLI 命令”npx capgo-capacitor-patch list --allnpx capgo-capacitor-patch doctornpx capgo-capacitor-patch apply有用的选项:
--root <dir>设置应用根目录。--phase package|native|all限制哪个补丁阶段运行。--platform ios|android在Capacitor钩子外应用平台过滤。--strict将选中的补丁失败作为错误处理。
工作流
标题为“工作流”- 安装
@capgo/capacitor-patch. - 运行
npx capgo-capacitor-patch list --all. - 将选中的补丁ID添加到
plugins.CapacitorPatch.patches. - 运行
npx capgo-capacitor-patch doctor --strict. - 运行
npx cap sync.
当选中的补丁目标是 @capacitor/cli, the patch applies to the installed CLI package and the next cap command uses the patched CLI code.