Capacitor has no built-in rollback for failed upgrades: track the native projects or regenerate them?
0 reputation · 06 Aug 2025, 18:57 UTC
0 reputation · 06 Aug 2025, 18:57 UTC
A Capacitor upgrade touches two layers: the npm packages (@capacitor/core, @capacitor/cli, and the platform packages) and the native ios/ and android/ projects, updated through the documented sync step that copies web assets and plugin configuration. Because those native directories are real, editable projects, there is no built-in rollback for a failed upgrade; recovery rests on version control or on regenerating a platform.
Two constraints complicate the choice:
ios/ and android/ preserves manual native customizations and makes a git revert a candidate recovery path, but it complicates regeneration-based rollback.Major-version upgrades can also require toolchain-side changes (Xcode, Android Studio, Gradle), so reverting app code may not undo everything an upgrade touched. Exact steps vary by major version and should be checked against the matching upgrade guide.
For a team standardizing on one approach:
package.json and reinstalling dependencies fully restore a working build when the native directories are tracked?35275 reputation · 06 Aug 2025, 19:29 UTC
Capacitor upgrades modify two independent layers: the npm packages (@capacitor/core, @capacitor/cli) and the native ios/ and android/ directories updated through the documented sync step. The framework has no built-in rollback mechanism, so recovery depends on version‑control reverts or regenerating the affected platform.
Confirmed facts: Capacitor does not undo a failed upgrade automatically. The native directories are real, editable projects; their state after a sync step reflects the last npx cap sync run, not necessarily the pre‑upgrade state.
Likely explanation: If you commit ios/ and android/ in git, a git revert or checking out a prior commit can restore the exact native build that worked before the upgrade, but subsequent npx cap sync may re‑apply the newer plugin configuration, potentially overwriting tracked changes. If you exclude them, platform regeneration via npx cap add ios (or android) is idempotent, but any hand‑edited Gradle or Podfile changes outside the sync configuration are not restored.
git checkout <previous-tag> -- ios/android, then npx cap sync, then npx cap build android|ios to verify the build succeeds.npx cap add ios (or android), re‑apply any custom native plugin hooks, run npx cap sync && npx cap build to confirm the build works.Missing diagnostic: Do you have hand‑edited Gradle or Podfile changes that aren’t tracked in the native directories? Answering this will determine whether tracking or regenerating platforms is the safer rollback path for your project.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.