Breaking Changes
This Documentation explains how to handle breaking changes in your Application using versioned Canaux. This approach allows you to maintain different versions of your Application while ensuring Utilisateurs receive compatible Mises à jour.
Exemple Scenario
Section titled “Exemple Scenario”Let’s say you have:
- Application Version 1.2.3 (old Version) - uses Production Canal
- Application Version 2.0.0 (Nouveau Version with breaking changes) - uses v2 Canal
- Live Mise à jour 1.2.4 (compatible with 1.2.3)
- Live Mise à jour 2.0.1 (compatible with 2.0.0)
Strategy: Always Use defaultChannel for Major Versions
Section titled “Strategy: Always Use defaultChannel for Major Versions”Recommended approach: Set a defaultChannel for every major version. This ensures you can always push updates to specific user groups without relying on dynamic channel assignment.
// Version 1.x releasesdefaultChannel: 'v1'
// Version 2.x releasesdefaultChannel: 'v2'
// Version 3.x releases (future)defaultChannel: 'v3'Benefits of this approach:
- Always have control over which Utilisateurs receive Mises à jour
- No dynamic Canal switching needed in your Application code
- Clear separation between different Application versions
- Flexibility to Pousser Mises à jour to any specific Version group
1. Créer Canal for Nouveau Version
Section titled “1. Créer Canal for Nouveau Version”# Create channel for version 2.xnpx @capgo/cli channel create v22. Mise à jour Capacitor Config for Version 2.0.0
Section titled “2. Mise à jour Capacitor Config for Version 2.0.0”Mise à jour your Capacitor config before Construction Version 2.0.0 for the Application Store:
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = { appId: 'com.example.app', appName: 'Example App', plugins: { CapacitorUpdater: { // ... other options defaultChannel: 'v2' // All 2.0.0 users will use v2 channel } }};
export default config;For version 1.x: If you didn’t set a defaultChannel initially, version 1.x users are on the production channel. For future major versions, always set a specific channel like v3, v4, etc.
3. Manage Separate Code Branches
Section titled “3. Manage Separate Code Branches”Créer separate git branches to maintain compatibility between Application versions:
# Create and maintain a branch for version 1.x updatesgit checkout -b v1-maintenancegit push origin v1-maintenance
# Your main branch continues with version 2.x developmentgit checkout mainCritical: Never push JavaScript bundles to older apps that expect native code/APIs they don’t have. Always build updates from the appropriate branch:
- v1-maintenance branch: For Mises à jour to 1.x apps (Production Canal)
- main branch: For Mises à jour to 2.x apps (v2 Canal)
4. Télécharger Bundles to Respective Canaux
Section titled “4. Télécharger Bundles to Respective Canaux”# For 1.x updates: Build from v1-maintenance branchgit checkout v1-maintenance# Make your 1.x compatible changes herenpx @capgo/cli bundle upload --channel production
# For 2.x updates: Build from main branchgit checkout main# Make your 2.x changes herenpx @capgo/cli bundle upload --channel v25. Activer Self-Assignment
Section titled “5. Activer Self-Assignment”# Allow apps to self-assign to v2 channelnpx @capgo/cli channel set v2 --self-assign6. Déployer to Application Store
Section titled “6. Déployer to Application Store”Construction and Déployer Version 2.0.0 to the Application Store. All Utilisateurs who Télécharger this Version (whether Nouveau Utilisateurs or existing Utilisateurs upgrading) will automatically use the v2 Canal because it’s configured in the Application Bundle.
No code changes needed! Since defaultChannel: 'v2' is bundled with the app store version, all users downloading version 2.0.0 will automatically use the correct channel.
Scaling to Future Versions
Section titled “Scaling to Future Versions”When you Libération Version 3.0.0 with more breaking changes:
# Create channel for version 3.xnpx @capgo/cli channel create v3// capacitor.config.ts for version 3.0.0const config: CapacitorConfig = { // ... plugins: { CapacitorUpdater: { defaultChannel: 'v3' // Version 3.x users } }};Now you can Pousser Mises à jour to any Version:
productionchannel → Version 1.x usersv2channel → Version 2.x usersv3channel → Version 3.x users
7. Cleanup (After Migration)
Section titled “7. Cleanup (After Migration)”Once all Utilisateurs have migrated to Version 2.x (count 3-4 months):
- Remove
defaultChannelfrom your Capacitor config - Supprimer the v2 Canal:
npx @capgo/cli channel delete v2- Supprimer the v1-maintenance branch:
git branch -d v1-maintenancegit push origin --delete v1-maintenanceThis approach ensures Utilisateurs only receive Mises à jour compatible with their Application Version
Always Test Mises à jour thoroughly in each Canal before Déploiement
You can safely Supprimer the v2 Canal in Capgo even if some Utilisateurs still have the Canal override. They will automatically receive Mises à jour from the Production Canal instead.
Maintaining Version 1.x Mises à jour
Section titled “Maintaining Version 1.x Mises à jour”To send Mises à jour compatible with Version 1.x:
- Switch to the v1-maintenance branch:
git checkout v1-maintenance- Make your changes and commit:
# Make 1.x compatible changesgit add .git commit -m "Fix for v1.x"git push origin v1-maintenance- Construction and Télécharger to Production Canal:
npx @capgo/cli bundle upload --channel productionKeep your v1-maintenance branch up to date with bug fixes that are compatible with Version 1.x, but never merge breaking changes from main