Nov 13, 2015

Cordova Plugin not found

Today I ran into Cordova plugin mapping issue.

Spent around 2 hours time to find out the root cause of the missing plugin,
it happens every time we rebuild iOS before any plugin is cloned.

To replicate the problem:

  1. In the cordova app project directory, remove "plugins" & "platforms" folders
  2. run `cordova platform add ios` to add platform directly (this step will fetch required plugins stated in config.xml and generate the iOS platform)
  3. Once iOS platform is ready, run `cordova run ios`.
The three steps above will lead you to problems like screenshot below.
plugins not found
Plugins not found
ERROR: Plugin 'File' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
["File334867545","File","requestAllPaths",[]]
ERROR: Plugin 'NetworkStatus' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
inJSON = ["NetworkStatus334867546","NetworkStatus","getConnectionInfo",[]]
ERROR: Plugin 'Device' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
788:2282747] -[CDVCommandQueue executePending] [Line 159] FAILED pluginJSON = ["Device334867547","Device","getDeviceInfo",[]]
In case I proceed by ignoring those "plugin not found" issues,
and run the buggy app on my device.
I'll end up getting errors like below in my debugging tool's console:
deviceready has not fired after 5 seconds
Channel not fired: onPluginReady
Channel not fired: onCordovaReady


To workaround this issue,
you'll need to rebuild the cordova iOS platform again with all the plugins fetched at first.

Now, since I have all the required plugins ready (from previous added iOS platform),
I'll keep the fetched plugins (inside plugins folder) and follow the steps below.

Remove and add back the iOS platform:
  1. cordova platform rm ios
  2. cordova platform add ios

No comments:

Post a Comment

Hey, thank you for spending time leaving some thoughts, that would be really helpful as encouragement for us to write more quality articles! Thank you!