18

currently I'm trying to install the BarcodeScanner Plugin for Phonegap Version 3.0.0. I can't find any working documentation on how to install it correctly and I didn't figure it out myself. So I would really appreciate any help!

Thank you in advance! Best regards, Andreas

user1448982
  • 1,200
  • 3
  • 12
  • 22

4 Answers4

21

Actually there are a couple of discussions about this issue on the github page of the plugin here and here.

I managed to have a version working in iOS and Android, you can check it here. There is another fork that has made a pull request to the original with changes for 3.0.0 even I am not quite sure that the plugin works in iOS.

Instructions to install (Using cordova cli)

  1. Download the repo using GIT or just a ZIP from Github.
  2. Add the plugin to your project (from the root of your project):

    cordova plugin add <path_download_plugin>

  3. You can start using plugins.barcodeScanner to invoke the plugin in your HTML/JS code.
  4. Do not forget to call cordova prepare to copy your files to each platform project.
Jonathan Naguin
  • 14,526
  • 6
  • 46
  • 75
  • Thank you! I will try your version, but can you tell me what commands to use to install it? I'm not quite sure if i have to use the plugman commands and/or the cordova plugin add command... and what parameters to add to the commands. – user1448982 Aug 09 '13 at 08:14
  • @user1448982 I edited my answer with instructions using cordova-cli. What structure are you following in your project? – Jonathan Naguin Aug 09 '13 at 08:24
  • Your solution works great, thank you! What do you mean by structure? – user1448982 Aug 09 '13 at 08:32
  • Well, you can have a `cordova-cli` style project, this is the new recommendation or the old structure style where you should use `plugman` – Jonathan Naguin Aug 09 '13 at 08:34
  • I'm using the `cordova-cli`, never used `plugman`, but I read about plugman in the plugin description so I wasn't sure if I have to use it... – user1448982 Aug 09 '13 at 08:37
  • 1
    I love you so much for `cordova prepare`. I've spent all day, all goddamn day, trying absolutely everything to get my plugins working, and now they are. Thank you – Mike Oct 18 '13 at 14:43
11

Here is my explanation based on Jonathan solutions. I tried his solution and succeeded but took more time. So I thought to explain steps I followed so that it can save someone's time.

Steps:-

1) First install cordova if not already installed using Cordova cli as below

Note: you must install node.js if not already installed.

npm install -g cordova
or
sudo npm install -g cordova

2) Go to the directory where you maintain your source code, and run a command such as the following:

  • $ cordova create hello com.example.hello HelloWorld

    The first argument specifies a hello directory to be generated for your project. Its www subdirectory houses your application's home page, along with various resources under css, js, and img, which follow common web development file-naming conventions. The config.xml file contains important metadata needed to generate and distribute the application.

    The other two arguments are optional: the com.example.hello argument provides your project with a reverse domain-style identifier, and the HelloWorld provides the application's display text

  • cd hello
  • cordova platform add ios
  • cordova plugin add https://github.com/jonathannaguin/BarcodeScanner.git
  • cordova build
  • cordova prepare

    3) remove all files from www folder except following

  • confix.xml
  • cordova_plugins.js
  • cordova.js
  • plugins (folder contaning barcodescanner.js)

    and your own index.html,js,css files

    I will be glad if it helps someone.

  • Anas Azeem
    • 2,820
    • 3
    • 24
    • 37
    Santosh Prasad Sah
    • 2,124
    • 1
    • 19
    • 14
    4

    i had the same error as @aruballo. To fix it i dropped the 3 the files from projectdir/Plugins/com.phonegap.plugins.barcodescanner/ inside the plugin directory in xcode.

    I also add one last problem with ARC restriction which was fixed by the answer from https://github.com/wildabeast/BarcodeScanner/issues/37#issuecomment-23320333 (must add -fno-objc-arc in Project - Buil Phases - compile source - CDVBarcodeScanner.mm line to resolve the problem / double click that line and add "-fno-objc-arc")

    enter image description here enter image description here

    user10078
    • 681
    • 7
    • 7
    • 2
      This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](http://stackoverflow.com/questions/ask). You can also [add a bounty](http://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question once you have enough [reputation](http://stackoverflow.com/help/whats-reputation). – midhunhk Aug 27 '13 at 08:06
    0

    i think,the documentation has a mistake.

    Change the "Class' from NSObject to PGbcsViewController

    After you add the .h,.cpp and .mm files to the project; if you search for 'PGbcsViewController' ,you can't find anything . (at least mine version of barcode plugin.) I corrected it as 'CDVbcsViewController' and i am using barcode scanner plugin without problem at ios,too.

    So parent class of view is important. You should check that.

    MugosDynamic
    • 99
    • 1
    • 7