capacitor-app-upgrade-v5-to-v6

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Capacitor App Upgrade v5 to v6

Capacitor 应用从v5升级到v6指南

Upgrade a Capacitor app from version 5 to version 6.
将Capacitor应用从版本5升级到版本6。

When to Use This Skill

何时使用此技能

  • User says the app is on Capacitor 5 and must move to v6
  • User wants the exact v5 to v6 migration path
  • User needs v6-specific native and package updates
  • 用户说明其应用使用Capacitor 5,必须升级到v6版本
  • 用户需要v5到v6的准确迁移路径
  • 用户需要v6专属的原生端与包更新内容

Live Project Snapshot

实时项目快照

Current Capacitor packages from
package.json
: !
node -e "const fs=require('fs');if(!fs.existsSync('package.json'))process.exit(0);const pkg=JSON.parse(fs.readFileSync('package.json','utf8'));const out=[];for(const section of ['dependencies','devDependencies']){for(const [name,version] of Object.entries(pkg[section]||{})){if(name.startsWith('@capacitor/'))out.push(section+'.'+name+'='+version)}}console.log(out.sort().join('\n'))"
来自
package.json
的当前Capacitor包信息: !
node -e "const fs=require('fs');if(!fs.existsSync('package.json'))process.exit(0);const pkg=JSON.parse(fs.readFileSync('package.json','utf8'));const out=[];for(const section of ['dependencies','devDependencies']){for(const [name,version] of Object.entries(pkg[section]||{})){if(name.startsWith('@capacitor/'))out.push(section+'.'+name+'='+version)}}console.log(out.sort().join('\n'))"

Procedure

操作步骤

  1. Start from the injected package snapshot and confirm the current
    @capacitor/core
    version.
  2. Update all
    @capacitor/*
    packages to the v6-compatible range.
  3. Review the v5 to v6 migration notes before editing native files.
  4. Run
    npm install
    .
  5. Sync with
    npx cap sync
    .
  6. Verify the iOS and Android builds.
  1. 基于注入的包快照,确认当前
    @capacitor/core
    的版本。
  2. 将所有
    @capacitor/*
    包更新到兼容v6的版本范围。
  3. 编辑原生文件前,请先查阅v5到v6的迁移说明。
  4. 运行
    npm install
  5. 执行
    npx cap sync
    同步资源。
  6. 验证iOS和Android构建是否正常。

Error Handling

错误处理

  • If the automated migration misses a package, update it manually before syncing again.
  • If iOS fails, check the deployment target and Xcode compatibility for Capacitor 6.
  • If Android fails, check the Gradle and Java requirements for Capacitor 6.
  • 如果自动迁移遗漏了某个包,先手动更新该包,再重新执行同步。
  • 如果iOS构建失败,请检查Capacitor 6要求的部署目标版本与Xcode兼容性。
  • 如果Android构建失败,请检查Capacitor 6要求的Gradle与Java版本要求。