How do you modify a PhoneGap / Cordova plugin and rebuild for iOS with the modification?

user3324565 picture user3324565 · Jan 5, 2015 · Viewed 10.1k times · Source

I am using the Cordova Splash Screen plugin (http://plugins.cordova.io/#/package/org.apache.cordova.splashscreen) and there is a bug with the current plugin that is causing the app to constantly crash. It appears the bug is documented here (https://issues.apache.org/jira/browse/CB-7497) but has not yet been fixed in an update, although a workaround is provided.

How do I incorporate the workaround in my project as I am unfamiliar with how to create or modify Cordova plugins. I edited the code to include the workaround mentioned, but how do I get the plugin to recompile for the actual Cordova or iOS project with the changes to the code that were made? I am a beginning to this, so if someone can provide easy to understand instructions on how I would go about incorporate this modified plugin back into my project I would appreciate it.

Answer

Michal Liďák picture Michal Liďák · Jul 13, 2015

If you want to change a downloaded plugin locally, you have to modify the plugin source files that are already copied in the corresponding platform folder, in your case ios folder.

For example the path of a source file of the barcode scanner plugin on Android platform looks like this:

<appname>\platforms\android\src\com\phonegap\plugins\barcodescanner\BarcodeScanner.java

On the other hand, the web portion of the plugin is copied from the plugin installation folder every time you run build command, so you need to change it there. Example:

<appname>\plugins\phonegap-plugin-barcodescanner\www\barcodescanner.js