Search code examples
ioscordovaionic-frameworkcapacitorionic5

Ionic 5 w/ Capacitor 'plugin_not_installed'


Ionic 5 with Capacitor getting 'plugin_not_installed' with plugin 'cordova.plugins.diagnostic'. Tried installing with this doc.

I have:

  • config.xml has <plugin name="cordova.plugins.diagnostic" spec="^5.30.0" />.
  • package.json has
"cordova": {
    "plugins": {
      ...
      "cordova.plugins.diagnostic": {}
      ...
    }
 }

and

"dependencies": {
    ...
    "@ionic-native/diagnostic": "^5.30.0",
    ...
    "cordova.plugins.diagnostic": "^6.0.2",
    ...
}

Here's my output for cordova plugin list

com.googlemaps.ios 3.9.0 "Google Maps SDK for iOS"
cordova-plugin-add-swift-support 2.0.2 "AddSwiftSupport"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-geolocation 4.1.0 "Geolocation"
cordova-plugin-googlemaps 2.7.1 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.2.1 "cordova-plugin-ionic-webview"
cordova-plugin-nativegeocoder 3.4.1 "NativeGeocoder"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova.plugins.diagnostic 6.0.2 "Diagnostic"

And have tried these commands:

ionic capacitor sync ios
cordova build
ionic build
ionic cordova run ios -l

Solution

  • First, when using Cordova plugin inside a capacitor project, use this commands.

    npm install cordova.plugins.diagnostic @ionic-native/diagnostic
    

    Refer docs for details

    Secondly, remove your platform and ios folders that have been already created. Then, for Capacitor follow these commands.

    ionic capacitor add ios
    ionic build
    ionic capacitor sync ios
    ionic capacitor open ios
    

    For any subsequent changes to your code, you just have to run

    ionic build && ionic capacitor sync ios (if you have added any new package/plugin)

    ionic build && ionic capacitor copy ios (if only code has been changed)

    You say your project is built on capacitor, then you don't have to run ionic cordova run ios command, or any cordova commands

    Refer this command docs