コードの破壊的変更
iOS
removeAllListeners メソッドの削除
プラグインの .m ファイルに CAP_PLUGIN_METHOD(removeAllListeners, CAPPluginReturnPromise) がある場合は、削除できます。このメソッドはすべてのプラグインで定義せずに利用可能になりました。
SPM サポートの追加
Capacitor 6 は実験的な SPM サポートを追加しました。プラグインにサポートを追加するには、既存のプラグインをSPMに変換する を参照してください。
definitions.ts
addListener のシグネチャが Promise のみを返すように変更されました。& PluginListenerHandle を削除してください。
addListener(
eventName: 'resume',
listenerFunc: () => void,
- ): Promise<PluginListenerHandle> & PluginListenerHandle;
+ ): Promise<PluginListenerHandle>;
プラグインでCapacitorを6.0にアップデートする
@capacitor/plugin-migration-v5-to-v6 を使用する
プラグインフォルダから npx @capacitor/plugin-migration-v5-to-v6@latest を実行すると、すべてのファイル変更が自動的に行われます。
ファイルを手動で更新する
package.json の更新
@capacitor/cli、@capacitor/core、@capacitor/android、および @capacitor/ios を latest-6 バージョンに更新します。
非推奨の compileSdkVersion を置き換え、targetSDK / compileSDK を 34 に更新する
# build.gradle
android {
- compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
gradle プラグインを 8.2.1 に更新する
dependencies {
- classpath 'com.android.tools.build:gradle:8.0.0'
+ classpath 'com.android.tools.build:gradle:8.2.1'
}
gradle ラッパーを 8.2.1 に更新する
# gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
- distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
kotlin_version の更新
プラグインが kotlin を使用している場合、デフォルトの kotlin_version を更新します。
# build.gradle
buildscript {
- ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.8.20'
+ ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.9.10'
repositories {