Breaking Changes
This documentation explains how to handle breaking changes in your app using versioned channels. This approach allows you to maintain different versions of your app while ensuring users receive compatible updates.
Example Scenario
Letβs say you have:
- App version 1.2.3 (old version) - uses production channel
- App version 2.0.0 (new version with breaking changes) - uses v2 channel
- Live update 1.2.4 (compatible with 1.2.3)
- Live update 2.0.1 (compatible with 2.0.0)
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'
1. Create Channel for New Version
# Create channel for version 2.xnpx @capgo/cli channel create v2
2. Update Capacitor Config for Version 2.0.0
Update your Capacitor config before building version 2.0.0 for the app 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;
3. Manage Separate Code Branches
Create separate git branches to maintain compatibility between app 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 main
Critical: 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 updates to 1.x apps (production channel)
- main branch: For updates to 2.x apps (v2 channel)
4. Upload Bundles to Respective Channels
# 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 v2
5. Enable Self-Assignment
# Allow apps to self-assign to v2 channelnpx @capgo/cli channel set v2 --self-assign
6. Deploy to App Store
Build and deploy version 2.0.0 to the app store. All users who download this version (whether new users or existing users upgrading) will automatically use the v2 channel because itβs configured in the app bundle.
Scaling to Future Versions
When you release 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 push updates to any version:
production
channel β Version 1.x usersv2
channel β Version 2.x usersv3
channel β Version 3.x users
7. Cleanup (After Migration)
Once all users have migrated to version 2.x (count 3-4 months):
- Remove
defaultChannel
from your Capacitor config - Delete the v2 channel:
npx @capgo/cli channel delete v2
- Delete the v1-maintenance branch:
git branch -d v1-maintenancegit push origin --delete v1-maintenance
Always test updates thoroughly in each channel before deployment
Maintaining Version 1.x Updates
To send updates 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
- Build and upload to production channel:
npx @capgo/cli bundle upload --channel production