Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add Updating to Capacitor 7 page #363

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 190 additions & 0 deletions docs/main/updating/7-0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
---
title: Updating to 7.0
description: Guide for updating Capacitor from v6 to v7 in your app
slug: /updating/7-0
---

# Updating from Capacitor 6 to Capacitor 7

In this guide, you'll find steps to update your project to the current Capacitor 7 version as well as a list of breaking changes for our official plugins.

## NodeJS 20+

Node 18 has reached end of active support on October 18th, 2023. Capacitor 7 requires NodeJS 20 or greater. (Latest LTS version is recommended.)

## Using the CLI to Migrate

Install the `next` version of the Capacitor CLI to your project:

```sh
npm i -D @capacitor/cli@next
```

Once installed, simply run the following to have the CLI handle the migration for you.

```sh
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.

## iOS

The following guide describes how to upgrade your Capacitor 6 iOS project to Capacitor 7.

### Upgrade Xcode

Capacitor 7 requires Xcode 16.0+.

### Raise iOS Deployment Target

Do the following for your Xcode project: select the **Project** within the project editor and open the **Build Settings** tab. Under the **Deployment** section, change **iOS Deployment Target** to **iOS 14.0**. Repeat the same steps for any app **Targets**.

Then, open `ios/App/Podfile` and update the iOS version to 14.0:

```ruby
platform :ios, '14.0'
```

## Android

The following guide describes how to upgrade your Capacitor 6 Android project to Capacitor 7.

### Upgrade Android Studio

Capacitor 7 requires Android Studio Ladybug | 2024.2.1 or newer and Java JDK 21. Java 21 ships with Android Studio Ladybug. No additional downloads needed!

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`.

![APG Upgrade Assistant](../../../static/img/v6/docs/android/agp-upgrade-assistant.png)

### Update Android Project Variables

In your `variables.gradle` file, update your values to the following new minimums

```groovy
minSdkVersion = 23
compileSdkVersion = 35
targetSdkVersion = 35
androidxActivityVersion = '1.9.2'
androidxAppCompatVersion = '1.7.0'
androidxCoordinatorLayoutVersion = '1.2.0'
androidxCoreVersion = '1.15.0'
androidxFragmentVersion = '1.8.4'
coreSplashScreenVersion = '1.0.1'
androidxWebkitVersion = '1.12.1'
junitVersion = '4.13.2'
androidxJunitVersion = '1.2.1'
androidxEspressoCoreVersion = '3.6.1'
cordovaAndroidVersion = '10.1.1'
```

### Update google services plugin

```diff
# build.gradle

dependencies {
classpath 'com.android.tools.build:gradle:8.2.1'
- classpath 'com.google.gms:google-services:4.4.0'
+ classpath 'com.google.gms:google-services:4.4.2'

```



### Update gradle plugin to 8.7.2

```diff
# build.gradle

dependencies {
- classpath 'com.android.tools.build:gradle:8.2.1'
+ classpath 'com.android.tools.build:gradle:8.7.2'

```

### Update gradle wrapper to 8.11.1

```diff
# gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
- distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
```

### Update kotlin version

If your project is using kotlin, update the `kotlin_version` variable to `'1.9.25'`.

### add navigation to configChanges

This is an optional change to prevent app restarts on some devices when using bluetooth keyboards.
Add `navigation` to `configChanges` of the app `activity` in `AndroidManifest.xml`.

```diff
- android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
+ android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation"
```

## Plugins

The following plugin functionality has been modified or removed. Update your code accordingly.

### Action Sheet

- `androidxMaterialVersion` variable has been updated to `1.12.0`.

### App

- Deprecated type `AppRestoredResult` was removed, use `RestoredListenerEvent`.
- Deprecated type `AppUrlOpen` was removed, use `URLOpenListenerEvent`.

### Browser

- `androidxBrowserVersion` variable has been updated to `1.8.0`.

### Camera

- `androidxExifInterfaceVersion` variable has been updated to `1.3.7`.
- `androidxMaterialVersion` variable has been updated to `1.12.0`.

### Device

- `getInfo()` no longer returns `diskFree`, `diskTotal`, `realDiskFree` and `realDiskTotal`, so the `PrivacyInfo.xcprivacy` entries for this plugin can be removed.
- Deprecated type `DeviceBatteryInfo` was removed, use `BatteryInfo`.
- Deprecated type `DeviceLanguageCodeResult` was removed, use `GetLanguageCodeResult`.

### Geolocation

- `playServicesLocationVersion` variable has been updated to `21.3.0`.


### Haptics

- Deprecated type `HapticsImpactOptions` was removed, use `ImpactOptions`.
- Deprecated type `HapticsNotificationOptions` was removed, use `NotificationOptions`.
- Deprecated type `HapticsNotificationType` was removed, use `NotificationType`.
- Deprecated type `HapticsImpactStyle` was removed, use `ImpactStyle`.

### Push Notifications

- `firebaseMessagingVersion` variable has been updated to `24.1.0`.

### Share

- `androidxCoreVersion` variable has been updated to `1.15.0`.

### Splash Screen

- Deprecated type `SplashScreenShowOptions` was removed, use `ShowOptions`.
- Deprecated type `SplashScreenHideOptions` was removed, use `HideOptions`.

### Status Bar

- `setOverlaysWebView()` and `setBackgroundColor()` are now supported on iOS.
- `androidxCoreVersion` variable has been updated to `1.15.0`.
1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module.exports = {
label: 'Upgrade Guides',
collapsed: false,
items: [
'main/updating/7-0',
'main/updating/6-0',
'main/updating/plugins/6-0',
'main/updating/5-0',
Expand Down