Getting Started
复制一个包含安装步骤和本插件的完整 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 sync直到您在 Capacitor 配置中选择补丁时,包都是无效的。
选择补丁 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.
干燥运行在应用之前
标题为“干燥运行在应用之前”使用 doctor 来检查是否选中的补丁与安装的包版本匹配:
npx capgo-capacitor-patch doctor --phase package --strict使用 apply 当您想要手动运行选中的补丁时:
npx capgo-capacitor-patch apply --phase package配置选项
配置选项部分| 选项 | 类型 | Default | Description |
|---|---|---|---|
recommended | boolean | false | Applies patches Capgo marks as recommended. |
patches | string[] | [] | Applies explicit patch IDs. |
disabled | string[] | [] | Skips selected patch IDs, even when recommended. |
strict | boolean | false | Throws when a selected patch is incompatible or cannot apply. |
CLI commands
Section titled “CLI commands”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. - Run
npx capgo-capacitor-patch doctor --strict. - Run
npx cap sync.
当选中的补丁目标是 @capacitor/cli,补丁将应用到安装的CLI包和下一个 cap 命令使用修补的CLI code。
继续从Getting Started
继续从Getting Started如果您正在使用 Getting Started 来规划原生插件工作,连接它与 使用@capgo/capacitor-patch 为原生能力在使用@capgo/capacitor-patch, Capgo 插件目录 为产品工作流程在 Capgo 插件目录, Capacitor 插件由 Capgo 为实现细节在 Capacitor 插件由 Capgo, 添加或更新插件 为实现细节在添加或更新插件,和 Ionic Enterprise 插件替代方案 为产品工作流程在 Ionic Enterprise 插件替代方案。