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

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 :/

The Crazy Ones

The original Apple “Think Different” commercial voiced by Steve Jobs.

Here’s to the crazy ones. The misfits. The rebels. The troublemakers. The round pegs in the square holes. The ones who see things differently. They’re not fond of rules. And they have no respect for the status quo. You can quote them, disagree with them, glorify or vilify them. About the only thing you can’t do is ignore them. Because they change things. They push the human race forward. And while some may see them as the crazy ones, we see genius. Because the people who are crazy enough to think they can change the world, are the ones who do.

The TV version was narrated by Richard Dreyfuss.