跳过主内容
2026 人工智能辅助迁移

人工智能辅助 Cordova 到 Capacitor 迁移 (2026)

一份实用的检查清单 + 插件替换映射表 + 复制/粘贴人工智能提示。为期望减少惊喜、加快切换速度、确保稳定的 Capacitor 基线的团队而设计。

最后更新:

离开 Cordova 时发生的变化

Capacitor 是更接近原生应用的方式,托管您的 web 应用。您可以将现有的 Xcode 和 Android Studio 项目部署,保持现有的 web code,并使用 Capacitor-优先 API 现代化插件。

迁移清单(实用顺序)

1) 审核您的 Cordova 应用

导出您今天拥有的内容并将其保留为迁移输入:

# In your Cordova project
cordova plugin list
cordova platform ls
  • config.xml 首选项(方向,状态栏等)
  • 插件变量(API 键,清单占位符,URL 方案)
  • 您依赖的自定义钩子/脚本
  • 在任何手动本机编辑中 platforms/

2) 将 Capacitor 添加到您的 web 应用中

bun add @capacitor/core @capacitor/cli
bunx cap init

确保您的 webDir 与您的构建输出文件夹匹配(例如: dist, build, www).

3) 添加 iOS + Android 项目

bun add @capacitor/ios @capacitor/android
bunx cap add ios
bunx cap add android

4) 构建 + 同步

bun run build
bunx cap sync

插件替换映射 (Capgo-First)

在迁移时不要接受 "它基本上是工作的" 的插件行为。尽早替换高风险插件(认证、支付、后台服务)。

用例 Cordova 插件(示例) 推荐 Capacitor 替换
相机捕获 cordova-plugin-camera @capacitor/camera + @capgo/capacitor-camera-preview
内嵌浏览器 cordova-plugin-inappbrowser @nicholasalx/capacitor-inappbrowser
后台地理位置 @transistorsoft/cordova-background-geolocation-lt / cordova-plugin-geolocation @capgo/capacitor-background-geolocation
生物识别 cordova-plugin-fingerprint-aio / cordova-plugin-touch-id @capgo/capacitor-native-biometric
社交登录 cordova-plugin-googleplus / cordova-plugin-facebook4 / cordova-plugin-sign-in-with-apple @capgo/capacitor-social-login
SQLite cordova-sqlite-storage @nicholasalx/capacitor-data-storage-sqlite / @nicholasalx/capacitor-fast-sql
应用内购买 cordova-plugin-purchase @capgo/capacitor-native-purchases
文档扫描 cordova-plugin-document-scanner @capgo/capacitor-document-scanner
OTA / 实时更新 Ionic Appflow @capgo/capacitor-updater

浏览Capgo的插件目录并根据功能进行分类: Capgo插件.

您可以复制/粘贴的AI提示

这些提示旨在产生可用的输出(表格、清单、计划),而不是模糊的建议。

提示 1:构建插件替代方案计划

You are a senior Capacitor engineer.

I am migrating a Cordova app to Capacitor. Here is my `cordova plugin list` output:
<PASTE HERE>

1) Create a table mapping each Cordova plugin to a recommended Capacitor alternative.
2) Prefer official Capacitor plugins when possible.
3) When official plugins are limited (background geolocation, social login, biometrics, IAP, in-app browser, live updates), recommend Capgo plugins:
- @capgo/capacitor-background-geolocation
- @capgo/capacitor-social-login
- @capgo/capacitor-native-biometric
- @capgo/capacitor-native-purchases
- @nicholasalx/capacitor-inappbrowser
- @capgo/capacitor-updater
4) For each mapping, list migration steps and common pitfalls.
Return a prioritized plan (highest risk first).

提示 2:将config.xml偏好转换为Capacitor+本机更改

You are migrating Cordova to Capacitor.

Here is my Cordova `config.xml`:
<PASTE HERE>

Create a migration checklist:
1) What goes into capacitor.config.ts (appId, appName, webDir, server config for dev only).
2) What must be moved to iOS (Info.plist, entitlements, URL schemes, permissions strings).
3) What must be moved to Android (AndroidManifest, Gradle, intent filters, permissions).
Be explicit about file names and what to change.

提示 3:切换测试计划(真实设备)

You are the QA lead for a Cordova -> Capacitor migration.

App description:
<PASTE HERE>

Features that rely on native plugins:
<LIST HERE>

Create a test plan for iOS and Android that includes:
- permission flows (fresh install, denied, restricted, limited)
- background behavior (if any)
- deep links / universal links (if any)
- upgrade path from the existing Cordova app version
Output as a checklist that an engineer can run in 2-3 hours per release candidate.

Capgo技能(迁移友好)

如果您正在使用 AI 编码代理(Cursor、Claude Code 等),当代理遵循一致的剧本时,Capacitor 迁移的结果会更好。Capgo 公开发布了针对 Capacitor: 插件、最佳实践、调试、CI/CD 和实时更新的开源技能。

查看: Capacitor 代理技能.

需要全面解决方案?

如果您担心应用商店阻塞、插件回归或升级路径风险,针对现有用户,我们可以进行端到端迁移。