Updating from Capacitor 5 to Capacitor 6
The breaking changes between Capacitor 5 and 6 are designed to be extremely minimal. In this guide, you'll find steps to update your project to the current Capacitor 6 version as well as a list of breaking changes for our official plugins.
NodeJS 18+
Node 16 has reached end-of-life as of September 11th, 2023. Capacitor 6 requires NodeJS 18 or greater. (Latest LTS version is recommended.)
Using the CLI to Migrate
Install the latest-6
version of the Capacitor CLI to your project:
npm i -D @capacitor/cli@latest-6
Once installed, simply run the following to have the CLI handle the migration for you.
npx cap migrate
If any of the steps for the migration are not able to be completed, additional information will be made available in the output in the terminal. The steps for doing the migration manually are listed out below.
Using the VS Code Extension to Migrate
If you have the VS Code extension installed, simply check out the recomendations section of the extension to find the option to migrate your project to Capacitor 6.
iOS
The following guide describes how to upgrade your Capacitor 5 iOS project to Capacitor 6.
Upgrade Xcode
Capacitor 6 requires Xcode 15.0+.
SPM Support
Converting from using Cocoapods to SPM is a pretty large topic we will cover in a different article, coming soon.
Register custom plugins
In Capacitor 6, plugin classes are no longer automatically registered. For npm installed plugins, the CLI will generate a list of plugin classes to register them programmatically. But users following the custom code guide for creating local plugins not distributed through npm, they will have to create a custom view controller and register their plugins.
Zooming
To match Android behavior, iOS apps are no longer zoomable by default. To enable zooming, check zoomEnabled
configuration option
Android
The following guide describes how to upgrade your Capacitor 5 Android project to Capacitor 6.
Upgrade Android Studio
Capacitor 6 requires Android Studio Hedgehog | 2023.1.1 or newer because of the usage of Gradle 8.2.
Once it's updated, Android Studio can assist with some of the updates related to gradle and moving package into build files. To start, run Tools -> AGP Upgrade Assistant
.
Update Android Project Variables
In your variables.gradle
file, update your values to the following new minimums
minSdkVersion = 22
compileSdkVersion = 34
targetSdkVersion = 34
androidxActivityVersion = '1.8.0'
androidxAppCompatVersion = '1.6.1'
androidxCoordinatorLayoutVersion = '1.2.0'
androidxCoreVersion = '1.12.0'
androidxFragmentVersion = '1.6.2'
coreSplashScreenVersion = '1.0.1'
androidxWebkitVersion = '1.9.0'
junitVersion = '4.13.2'
androidxJunitVersion = '1.1.5'
androidxEspressoCoreVersion = '3.5.1'
cordovaAndroidVersion = '10.1.1'
Update google services plugin
# build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
- classpath 'com.google.gms:google-services:4.3.15'
+ classpath 'com.google.gms:google-services:4.4.0'