Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

TiBar: ZBar integration module for Titanium Mobile

Hello Titanium community,

we are proud to present our effort towards the integration of the ZBar project into a custom Titanium Mobile module.

We have opened a google code project namely TiBar which describes the usage of the module from titanium developer point of view.

The TiBar module extends the Titanium Mobile SDK 1.4.0 with rudimentary capabilities of scanning barcodes and QR-Codes.

The usage is as simple as usual titanium API calls:

//reference the module
var TiBar = Titanium.TiBar;

//use the scan capability
TiBar.scan({
    success:function(data){
            if(data && data.barcode && data.symbology){
                Ti.API.debug("Barcode: " + data.barcode + " Symbology: "+data.symbology);
            }

    }
});

Please feel free to comment and contribute.
Current contributors: martin and lukasz

— asked August 6th 2010 by Martin Lasak
  • barcode
  • module
  • qrcode
  • reader
  • zbar
5 Comments
  • Hey guys,
    I love the module. It works great! My one question is whether it's possible to scan the barcode directly from the camera screen? There are some apps out there that you don't have to hit a "Scan" button – it automatically detects that there's a QR code there and then scans it. Is that possible with TiBar?

    Thanks.

    — commented October 14th 2010 by Brian Seitel
  • Hi Martin,
    How can I access the image if i configured it like "takesPicture":true in the config parameters??
    Thanks

    — commented October 18th 2010 by Sebas Moranta
  • This project looks fantastic. I am dying to get your most recent demo app running, but I am experiencing some issues on build. I would HUGELY appreciate any guidance.

    I have created two pasties containing (hopefully) the most important sections of my log file.

    Log file section from first warning to EOF:
    http://pastie.org/1247683

    Log file section from Header to 100K pastie limit:
    http://pastie.org/1247692

    I am running:
    Snow Leopard 10.6.4
    TI: 1.4.1.1
    IOS: 4.1

    Many thanks in advance!

    — commented October 25th 2010 by Michael Weinberg
  • For the ones asking about how to access the camera, there is is an associative array sourceType, with the following items: {"Library":false}, {"Camera":false}, {"Album":true}. add it to the config parameters while setting 'Camera': true , of course.

    — commented November 18th 2010 by Richard Lustemberg
  • To answer Brian Seitel's question from 2 years ago, you can set classType: "ZBarReaderViewController" in order to have it auto capture the code rather than having to press a Scan button.

    — commented November 27th 2012 by Justin Toth

35 Answers

  • Is there any way to make it work for Android?

    — answered June 5th 2011 by Jose Simoes
    permalink
    2 Comments
    • i found that ZBar only provides its SDK on iOS and not on Android so, i don't think it can have Android parallel

      — commented August 16th 2012 by Perminder Singh Bhatia
    • Use this one for Android: https://github.com/mwaylabs/titanium-barcode

      — commented November 27th 2012 by Justin Toth
  • Hi Titanium community!

    We have updated our TiBar module. The module allows you now to configure the barcode scanner (for example you can set the symbology). We added also error and cancel callbacks. For more information and TiBar Test App see project page: http://code.google.com/p/tibar/

    Best regards.

    Lukasz and Martin

    [UPDATE 12.10.2010] Source code: http://code.google.com/p/tibar/source/browse/#svn/trunk/tibar Developer tutorial and new version is coming soon.

    — answered September 14th 2010 by Lukasz Radziwonowicz
    permalink
    2 Comments
    • I'm having a bit a problems with the following config:

      TI Developer: 1.2.2
      TI Mobile SDK: 1.5.1
      TI Bar: 0.4.1

      Everytime I try to build, it always reverts back to iOS 4.1 SDK. The workaround on the TiBar page works when I run in the simulator (annoying that I have to do it everytime, but at least it work). But never seems to be able to do it when I want to execute on device. Seems like TI Developer rebuilds and removes the frameworks/project OS configuration everytime. Any suggestions on a workaround or pointers?

      — commented December 29th 2010 by Tony Kueh
    • I seem to have resolved the build issue. However, now it appears that during runtime, the system is unable to find the tibar module.

      — commented January 1st 2011 by Tony Kueh
  • I'm trying to get it work in Titanium, but it always fails when I relaunch it in Titanium. It doesn't fail in X-Code. I made all changes you explained on the Google code page, except changing the base SDK version (I just have iOs 5). Does the module work on iOs 5 ?

    — answered January 24th 2012 by Xavier C.
    permalink
    2 Comments
    • All is OK in X-Code. In Titanium I've got this error message :

      [ERROR] clang: error: linker command failed with exit code 1 (use -v to see invocation)
      [ERROR] 
      [ERROR] Error: Traceback (most recent call last):
      

      — commented January 24th 2012 by Xavier C.
    • Add this to your module.xcconfig to fix that error:

      OTHER_LDFLAGS=$(inherited) -framework AVFoundation -framework CoreMedia -framework CoreVideo -framework QuartzCore /usr/lib/libiconv.dylib

      — commented November 27th 2012 by Justin Toth
  • martin - this is absolutely awesome. thanks so much for sharing this. i really can't wait to use this in an upcoming project!

    — answered August 30th 2010 by danno watts
    permalink
    0 Comments
  • Hi Martin,

    I have no use for this at the moment, but on behalf of the community thanks for the share

    Richie

    — answered August 6th 2010 by Richie Mortimer
    permalink
    1 Comment
    • Hi Richie,
      we spend many many hours to get it running, so it was our duty to share the results ;) Of course, there is much room for improvement, e.g. Android support. But, our next steps will be: the detailed tutorial on "how to build a titanium mobile module based on third party libraries" and providing the complete code which was needed to build the TiBar module. So, keep an eye on the TiBar project if you need barcode capabilities sometime. Thanks.

      — commented August 6th 2010 by Martin Lasak
  • It is a very good news, thank you guys for the works!

    Btw, is there any plans for developing an android version later on?

    — answered August 8th 2010 by Aee Q
    permalink
    2 Comments
    • Yes, of course, it is already on our to-do list. The only problem is that ZBar directly does not support android. The possible solution will be to use zxing library. They have already android app and probably it would be easier to integrate it as a titanium module.

      — commented August 9th 2010 by Lukasz Radziwonowicz
    • Any news about the android implementation?

      — commented August 23rd 2010 by Michael G.
  • Really nice, thank you very much, I hope this great example and your upcoming tutorial will trigger more developers to make such modules. I will be watching the project site for some more documentation on how to use the TiBar module (if it provides more methods / options than already given in the example). Good luck!

    — answered August 8th 2010 by Victor van Rijn
    permalink
    2 Comments
    • Hi Victor! Thanks a lot for the motivating words. There is still a lot to do and in first place we want to publish developer's guide to creating custom titanium module. I hope we manage to write it this week. Next step is to map complete ZBar API into TiBar module, so you can use all ZBar features in your titanium project. Cheers!

      — commented August 9th 2010 by Lukasz Radziwonowicz
    • I think someone else already posted this suggestion for another Titanium mobile module, but I would like to mention this one here to have you guys check it out: sharekit It's another open-source project which provides a really nice and flexible module for 'sharing' functionality across multiple webservices in your iPhone app. It would be nice if you could examine and review this site to check if it would be possible to create a Titanium module for this. I think a lot of Titanium users would really love to incorporate this kind kind of functionality in their apps. (just as I think a lot of us will be using TiBar in future projects) Perphaps you guys or some other skilled obj-c members of the community could then collaborate on this or keep this one in mind for some future experiment. Good luck with TiBar and thx again

      — commented August 16th 2010 by Victor van Rijn
  • Great stuff! Looking forward to watching the progress of this.

    I have a lot of QRCode ideas ;)

    — answered August 30th 2010 by Kosso
    permalink
    1 Comment
    • just installed it and it works perfectly! :) GREAT WORK! thank you!

      — commented September 4th 2010 by Kosso
  • hi. first of all, congratulations for this great module. it's very usefull!. could you please tell us if there is a way to edit the "i" button? I cant find any documentation telling us how to do it.

    thank's!

    — answered September 1st 2010 by Sebas Moranta
    permalink
    4 Comments
    • "i" button should load help page. This is ZBar library feature, but we could not figure out how to include it in our module. I hope I can find some time to investigate this problem.

      Cheers, Lukasz

      — commented September 2nd 2010 by Lukasz Radziwonowicz
    • A nice solution would be to have an aditional parameter in the scan-method, something like {'helpURI':'App://Resources/help.html'}

      A quick solution could be to hide the "i" button, if {'helpURI':''}

      Would the quick solution be sufficient for you?

      — commented September 3rd 2010 by Martin Lasak
    • Hi.Martin, Lukasz, thanxs for the replies. The quick solution would be fine. what should i do to hide the 'i' button? thanxs!!!

      — commented September 6th 2010 by Sebas Moranta
    • If you include a "zbar-help.html" file in the the Resources folder of your project, it will be loaded when the "i" icon is clicked. We're going to write up some tips on getting a good scan, how to use the scanner for our app, etc. to the page.

      — commented September 9th 2010 by Michael Buckbee
  • Hi Martin,

    thanks for the great module. I have it working perfectly in 1.4.0, but I wanted to use it in the continuous 1.4.1 builds and I go through the install but get an error trying to run it:

    Traceback (most recent call last):
    File "/Library/Application Support/Titanium/mobilesdk/osx/c-1.4.1/iphone/builder.py", line 10, in <module>
    from compiler import Compiler
    File "/Library/Application Support/Titanium/mobilesdk/osx/1.4.1/iphone/compiler.py", line 12, in <module>
    from tiapp import *
    ImportError: No module named tiapp

    I added the libraries to the 1.4.1 xcode project and then created a new project, but no go. Hopefully I'm missing something simple.

    Thanks for your help.

    — answered September 3rd 2010 by Lee Strasheim
    permalink
    3 Comments
    • Hello Lee,
      We run 1.4.1 with the TiBar module without any problems.
      Could it be that you have a typo (tiapp instead of tibar?) in your App's tiapp.xml?
      Our config at this point is:

      <modules>
       <module version="0.1">tibar</module>
      </modules>
      

      Best regards.

      — commented September 3rd 2010 by Martin Lasak
    • Thanks for your quick reply Martin. There wasn't a type in tiapp.xml so I downloaded today's current build and reinstalled tibar. It's working again now with 1.4.1.
      I also found that putting a custom zbar-help.html file in the Resources folder now works. Touching the i now shows my help file.

      — commented September 3rd 2010 by Lee Strasheim
    • Thanks Lee for the tip. This works :) Cheers

      — commented September 8th 2010 by Lukasz Radziwonowicz
  • Awesome, guys!
    Thank you very much.

    — answered September 3rd 2010 by Olivier Morandi
    permalink
    0 Comments
  • Anybody had a chance to try this out on the new iPod Touch yet? I have a client who bought an iPod Touch to try it out but he is miles away and I would really like a developer's take on whether it works or not. I am going to have him deploy my app to his device to check it out but if it doesn't work I'm not sure I'm going to get "developer friendly" feedback.

    — answered September 8th 2010 by Jeff Huelsbeck
    permalink
    0 Comments
  • Just to let you guys know, this also works on the new iPod Touches! Thanks for the hard work!

    — answered September 8th 2010 by Jeff Huelsbeck
    permalink
    2 Comments
    • Hello Jeff,
      thank you for pointing that out! Would be really nice if someone could share some experiences with TiBar on an iPhone 4 as well.
      Best regards.

      — commented September 12th 2010 by Martin Lasak
    • Sorry for the late response, you probably already know this but it works with iPhone 4 running iOS 4.1 as well.

      — commented November 16th 2010 by Jeff Huelsbeck
  • Do you have plans to make this available for Android phones?

    — answered September 11th 2010 by Tim Poulsen
    permalink
    2 Comments
    • Hi Tim, the answer to your question is simple: Yes!
      We need the TiBar module on the android platform, too. There are two obstacles: 1) How to develop titanium modules for android platform? Haven't seen a Module SDK like for iPhone 2) We are scared of porting zbar to android ;) But for that we could rely on Zxing project, which works fine for android. So, the goal is, that that the js codebase stays the same on all platforms, with the above described call.

      Best regards.

      — commented September 12th 2010 by Martin Lasak
    • Use this module for Android:

      https://github.com/mwaylabs/titanium-barcode

      — commented November 27th 2012 by Justin Toth
  • Hi Martin

    I am integrating this into an existing iPhone app. Its great.

    In version 0.2 (I think), the barcode scanner displayed some tracking lines around the barcode when it came into focus, and the scan callback was activated automatically. I prefer this to having a scan button on the camera screen. Has this functionality been deprecated in version 0.3 or is there some config i need to set?

    Ah - figured this out - need to change the view controller config option.

    Thanks
    Jon

    — answered September 17th 2010 by Jon Clarke
    permalink
    0 Comments
  • I am having some issues getting this installed. I have the lib installed into my xcode project. When I tell the TI project to install the module it fails

    <modules>
    <module version="0.3">tibar</module>
    </modules>

    I have tried with 1.4.0 and 1.4.1.1, both seem to fail. I am also running the iOS 4.1 SDK.

    It hangs when it's building the app.

    — answered September 28th 2010 by Mark Stocks
    permalink
    1 Comment
    • Hi Mark,

      is it possible for you to show us the build.log file?
      is located in your app-folder/build/iphone/build
      its nearly completely impossible for us to analyse your problem otherwise.
      take www.pastie.org for the build.log to post.

      Best regards,
      Martin

      — commented September 28th 2010 by Martin Lasak
  • Hi there,

    I have the same problem here, failed with 1.4 and 1.4.1.1.

    I cannot paste my log because it's over 100kb (pastie's limit).

    Here is the Titanium error, I don't know if it could be useful for you :

    Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
    mmap$UNIX2003 called from function _Z20TCMalloc_SystemAllocmPmm in image Zbar.
    Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
    pthread_cond_init$UNIX2003 called from function _ZN3WTI17TCMalloc_PageHeap4initEv in image Zbar.
    Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
    pthread_cond_wait$UNIX2003 called from function _ZN3WTI17TCMalloc_PageHeap15scavengerThreadEv in image Zbar.
    Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
    mprotect$UNIX2003 called from function _ZN2TI3JIT35privateCompileCTIMachineTrampolinesEPN3WTI6RefPtrINS_14ExecutablePoolEEEPNS_12TiGlobalDataEPNS_21MacroAssemblerCodePtrES9_S9_S9_ in image Zbar.
    
    — answered September 30th 2010 by Alexandre Lobanev
    permalink
    0 Comments
  • Hi Lukasz and Martin

    Can you share on how you did the integration with Titanium please? I've been watching the Google code page which indicates you were going to post this but nothing has appeared yet!

    many thanks!

    — answered October 18th 2010 by Jon Clarke
    permalink
    0 Comments
  • Hi Martin,

    How can I access the image if i configured it like "takesPicture":true in the config parameters??
    Thanks

    — answered October 18th 2010 by Sebas Moranta
    permalink
    0 Comments
  • I have a demo app out to some testers (running 0.1) and one of them has updated to the latest iOS 4.2 GM dev build and says that the app freezes when hitting the scan button. Is this a problem with 0.1 only or is it seen in 0.3 too? And if so how long until the workaround (seen here: tibar issues) is implemented? Seems like a quick fix but I may be wrong.

    I'm holding off on updating my dev phone to 4.2 so I can continue to work on my app without the freezing so I'm unable to test this myself.

    — answered November 16th 2010 by Jeff Huelsbeck
    permalink
    0 Comments
  • Thought I would throw in my 2 cents. I was able to get the latest build working on a 3G. The catch, only the QR-Code seems to work. However, it works pretty well. I was using the TiBar Test app with the zBarReaderController, Camera, and any camera mode worked.

    — answered November 30th 2010 by Tony Nuzzi
    permalink
    0 Comments
  • And updates on Android (zxing) support? Very interested in knowing this.

    — answered May 24th 2011 by Kapil Israni
    permalink
    0 Comments
  • I have an issue when I try to install the plugin (maybe because I'm on OS X Lion) but libiconv doesn't seem to work when I build the project…

    — answered October 6th 2011 by Pablo Albrecht
    permalink
    0 Comments
  • Will this module work on Android too?

    Thanks

    — answered November 4th 2011 by Allan Brazute
    permalink
    1 Comment
    • Allan, I don't think this works with Android but the latest Ti Barcode module works perfectly for Android.

      — commented November 4th 2011 by Danny Migliorisi
  • Hi Martin
    Your module is very really good, except an issue with scanning barcode type EAN-13, sometimes it works but sometimes it can detect incorrectly. For example the barcode 4030287747295 sometimes is recognized as 4030227147895 or 4030227147291.
    Please help us ASAP !
    Thanks so much

    — answered August 14th 2012 by Hung Nguyen Uy
    permalink
    0 Comments
  • Hi Martin Your module is very really good, except an issue with scanning barcode type EAN-13, sometimes it works but sometimes it can detect incorrectly. For example the barcode 4030287747295 sometimes is recognized as 4030227147895 or 4030227147291. Please help us ASAP ! Thanks so much

    — answered August 14th 2012 by Hung Nguyen Uy
    permalink
    0 Comments
  • So, this only works on iPhone 3GS and higher, yes? I'm guessing this because it looks like it requires video which, sadly, my 3G doesn't have (and nothing is happening when I press the "scan" button (when on the phone).

    — answered August 7th 2010 by Rafael Hernandez
    permalink
    1 Comment
    • Hi Rafael,
      you are absolutely right. Our module is based on ZBar and it does not support iPhones prior to 3GS due to the missing auto-focus. As far i can remember, there was somewhere a explicit requirement in the ZBar library code like: 'if we are on 3GS and higher then preceed…'
      Anyway, thank you for your comment, it reminds me of either to do some exception handling for 2G and 3G or search for a working solution for this devices. Maybe someone knows other libraries than ZBar and zxing we could use for those devices instead?
      Meanwhile i'll add '>=3GS' to the PREQUISITES section in our tutorial. Thanks.

      — commented August 7th 2010 by Martin Lasak
  • This is awesome! Love to see you expand into other modules as well :)

    — answered August 8th 2010 by Sj Singh
    permalink
    0 Comments
  • This is wonderful! I was just talking with some friends about how cool it would be to use this functionality in a project and did a little search and this popped up. Thanks for this, I've built the test app and am already starting to integrate it into my app!

    I was wondering though, any other callback functions besides success? I want to give the user feedback when the code is scanned like vibrating the phone or triggering a sound? Maybe in a future version? I'll play around with it, maybe it will be responsive enough in the success callback.

    Thanks again, I love it! Keep up the good work!

    — answered August 14th 2010 by Jeff Huelsbeck
    permalink
    2 Comments
    • Hello Jeff,
      unfortunately we had not much time this week to complete the detailed 'how-to' we promised :( But we're working on it.

      Its easy to extend the API of the module. For now, there is only one function 'scan' with the mentioned object as parameter including the success callback, which is called after the barcode was recognized. The response time in our tests was amazing. With normal day light circumstances the response was much under one second!

      What is urgently needed beside the plain 'barcode'-number is the information about the symbology of the barcode: EAN,CODE128,ISBN and so on… The next release of the TiBar module will include this feature for sure.

      It would be real great if everyone would capture his ideas and wishes for new functionality by opening a 'New issue' at the TiBar project page http://code.google.com/p/tibar
      It easier than for us and the others to track, what was done and what should be done.

      Thank you for your comment and your participation.

      — commented August 14th 2010 by Martin Lasak
    • Oh, I got it to work by vibrating and playing a sound on complete. Works perfect, gives the proper feedback and feels right, thanks for the heads up though.

      — commented September 8th 2010 by Jeff Huelsbeck
  • thank you guys! It's run just great for this first version.

    — answered August 14th 2010 by Nicolas Arcay Bermejo
    permalink
    0 Comments
  • This is just the kind of thing I need. Keep up the good work here. Thanks!

    — answered August 16th 2010 by Joey Kanner
    permalink
    0 Comments
  • Hi there,

    Is there a way to have a single application include this module and be able to run it on an iPhone 3G without the feature? I mean, checking in the code the OS version to enable the feature or not.

    Right now, if I include this module, I get this error when booting the app in a 3G device (far before the JS code is run):

    [Session started at 2010-08-24 15:42:25 -0700.]
    GNU gdb 6.3.50-20050815 (Apple version gdb-1470) (Thu May 27 05:54:06 UTC 2010)
    Copyright 2004 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB.  Type "show warranty" for details.
    This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys002
    Loading program into debugger…
    warning: Unable to read symbols from "iAd" (not yet mapped into memory).
    warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.1.3/Symbols/System/Library/Frameworks/CoreMedia.framework/CoreMedia" (file not found).
    warning: Unable to read symbols from "CoreMedia" (not yet mapped into memory).
    warning: Unable to read symbols from "CoreVideo" (not yet mapped into memory).
    Program loaded.
    target remote-mobile /tmp/.XcodeGDBRemote-74021-97
    Switching to remote-macosx protocol
    mem 0x1000 0x3fffffff cache
    mem 0x40000000 0xffffffff none
    mem 0x00000000 0x0fff none
    run
    Running…
    [Switching to thread 11779]
    [Switching to thread 11779]
    sharedlibrary apply-load-rules all
    continue
    dyld: Library not loaded: /System/Library/Frameworks/CoreMedia.framework/CoreMedia
      Referenced from: /var/mobile/Applications/1D7C10DC-BBB8-4284-83C7-D30EE1BE0BD2/Interplay.app/Interplay
      Reason: image not found
    Data Formatters temporarily unavailable, will re-try after a 'continue'. (Not safe to call dlopen at this time.)
    mi_cmd_stack_list_frames: Not enough frames in stack.
    mi_cmd_stack_list_frames: Not enough frames in stack.
    (gdb)
    

    I hope there is a way because it would be very hard to have two separate projects, one for iPhone 3G and other for iPhone 3GS and newer.

    — answered August 24th 2010 by Eneko Alonso
    permalink
    1 Comment
    • Hi Eneko! ZBar library does not supports iPhone 3G (see: http://zbar.sourceforge.net/iphone/index.html). Do you use iOS 4.x? For older iOS versions you have to set type for some linked libraries as "Weak" (AVFoundation.framework, CoreMedia.framework, CoreVideo.framework, see build settings for ZBar) I hope this helps.

      Cheers, Lukasz

      — commented August 31st 2010 by Lukasz Radziwonowicz
  • Doh! Double post, sorry!

    — answered September 8th 2010 by Jeff Huelsbeck
    permalink
    0 Comments
  • Hi Martin,

    We are using your module and it works great!! We have some questions about how to configure the 'i' button. is that possible?? in objective-C? thanxs!!

    — answered August 30th 2010 by Sebas Moranta
    permalink
    1 Comment
    • If you look in the titanium console you should see that this is hitting a local url (zbar-help.html I believe). You just need to create that file and populate it with your info (I believe this has changed in 0.3 but haven't dug into it yet).

      — commented November 16th 2010 by Jeff Huelsbeck
  • tibar is not work anymore. I hate Titanium! It is not good solution!. no QR code! no PayPal! I am anti Titanium now because QRCode!

    — answered September 15th 2011 by Sang-Taik Jung
    permalink
    2 Comments
    • Wow, why don't you tell us how you really feel?

      Perhaps you'd get farther by detailing what error you get instead of just saying "is not work anymore". The chances are good that someone would try to help you solve it if you provided enough information to be able to help you. The module still works for others.

      If you'd rather just rant and go find another development tool, then I hope you find what you are looking for.

      — commented September 15th 2011 by Doug Handy
    • It definitely works for QR codes…

      — commented November 27th 2012 by Justin Toth
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.