Plugin ‘BarcodeScanner’ not found, or is not a CDVPlugin.

1 Comment

While testing a Phonegap app on an iOS device with the BarcodeScanner plugin, I encountered the following error:

ERROR: Plugin 'BarcodeScanner' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.

I could not find any solutions that worked for me online, so I had to experiment and here’s what I found to work for me.

After creating the Phonegap app, downloading the plugin and using your own code or this demo:

  1. Copy barcodescanner.js to <your_app>/www/js
  2. Wrap all the code with:
    cordova.define("com.phonegap.plugins.barcodescanner.BarcodeScanner", function(require, exports, module) {
    /* barcodescanner.js goes here */
    });
  3. Adjust the path to barcodescanner.js in the script tag in index.html
    src="js/barcodescanner.js"
  4. Build the app in terminal:
    phonegap build ios
  5. Deploy app to iOS device on Xcode

Let me know if this works for you or if you found other solutions. Curiously, building the app more than once in terminal makes this not work :/

Comments

I had the same symptom, but a different cause: The file CDVBarcodeScanner.mm was not set to compile in XCode. I don’t know how that happened, but for the benefit of anyone else coming here via Google, here is the link to the solution:

http://stackoverflow.com/a/21148428/1713762

by Jens Neubauer

©2018 LTwebs