From ce9d50585b1cab183245197878bf625cf0289275 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Thu, 21 Mar 2024 19:40:47 +0100 Subject: [PATCH] fix: inject cordova files if a cordova plugin is present (#7363) --- cli/src/util/iosplugin.ts | 5 +++++ ios/Capacitor/Capacitor/CapacitorBridge.swift | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cli/src/util/iosplugin.ts b/cli/src/util/iosplugin.ts index 3ef3f6c86..725a03e24 100644 --- a/cli/src/util/iosplugin.ts +++ b/cli/src/util/iosplugin.ts @@ -7,6 +7,7 @@ import { } from '@ionic/utils-fs'; import { resolve } from 'path'; +import { getCordovaPlugins } from '../cordova'; import type { Config } from '../definitions'; import type { Plugin } from '../plugin'; @@ -75,5 +76,9 @@ export async function generateIOSPackageJSON( ): Promise { const fileList = await getPluginFiles(plugins); const classList = await findPluginClasses(fileList); + const cordovaPlugins = await getCordovaPlugins(config, 'ios'); + if (cordovaPlugins.length > 0) { + classList.push('CDVPlugin'); + } writePluginJSON(config, classList); } diff --git a/ios/Capacitor/Capacitor/CapacitorBridge.swift b/ios/Capacitor/Capacitor/CapacitorBridge.swift index 495a747d4..644076cec 100644 --- a/ios/Capacitor/Capacitor/CapacitorBridge.swift +++ b/ios/Capacitor/Capacitor/CapacitorBridge.swift @@ -293,10 +293,11 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol { for plugin in registrationList.packageClassList { if let pluginClass = NSClassFromString(plugin) { - if class_getSuperclass(pluginClass) == CDVPlugin.self { + if pluginClass == CDVPlugin.self { injectCordovaFiles = true + } else { + pluginList.append(pluginClass) } - pluginList.append(pluginClass) } } }