Integrating ZXing QR Code reader in iPhone / iOS applications

I spent a lot of time in integrating the QR code reader in iOS applications. I like to share you the steps and let you know the basic bugs that may happen during the integration process and how to debug that too :)


Step 1 Download the latest code for QR code reader, zxing framework from github here.


Step 2 Drag and drop the ZXingWidget.xcodeproj file to your project.


Step 3 Copy the cpp folder from downloaded files (zxing-2.0) to your project. (The download files (zxing-2.0) depends upon the version that has been downloaded from github.)


Step 4 Copy the iphone folder from downloaded files (zxing-2.0) to your project. (The download files (zxing-2.0) depends upon the version that has been downloaded from github.)


Step 5 Add the following frameworks to your project. 
Click on Project name -> Target -> Build Phases -> Link with libraries
  • AudioToolbox.framework
  • AddressBookUI.framework
  • AddressBook.framework
  • CoreVideo.framework
  • CoreMedia.framework
  • AVFoundation.framework
  • libiconv.dylib
  • libZXingWidget.a


Step 6 Set the zxing widget library as your target dependency.
Click on Project name -> Target -> Build Phases -> Target Dependencies
Select the file, ZXingWidget


Step 7 Set your target Header Search path to refer the zxing framework classes.
../cpp/core/src    Don't select this option
../ZXingWidget/Classes   Select this option


Note: These class paths varies based on the location where you paste the zxing /cpp and /iphone folder. Make appropriate changes to build without any errors.


Step 8 Important: Rename your view controller (the class where you are going to implement ZXingWidgeController class) from "*.m" to "*.mm"


Step 9 Now, implement the ZXingWidgetController class in your header file and QRReader class in your .m file. It will build without any errors.


And, its your turn now to go ahead with QR code reader coding :)


Bugs:
1. "ZXingWidgetController.h file not found"
       This means the library path mentioned in Step 7 is not correct. The compiler is unable to find the class files.


2. "iostream error" / " file not found"
       This means, Step 8 is not done. Replace the suffix for the view controller you are integrating the QR Code. It should be "*.mm" instead of "*.m"



Comments

  1. Awesome post.Learn how to incorporate QR codes in your web apps to deliver quick information directly to your users' mobile device http://blog.caspio.com/web_apps/4-ways-to-use-qr-codes-in-your-web-apps/

    ReplyDelete
  2. Hi, Thanks for your great tutorial. By playing with the example file in ZXing i found that they are all using the AVfoundation the capture method. I would like to ask how can I use the old way which sending a UIImage to the decoder and decode. I would like to pick Image from Imagepicker.

    ReplyDelete
  3. for the Anonymous person who asked how to decode a image from the photo library, have a look at this link
    http://caydenliew.com/2011/12/qrcode-reader-with-zxing-library/
    He has made a small modification to the library so that the QRCode reader can read from image as well instead of just camera.

    ReplyDelete
    Replies
    1. yaar Azeem, tu kiski side se hai????? :(

      Delete
  4. clang: error: invalid deployment target for -stdlib=libc++ (requires iOS 5.0 or later)
    Command
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

    Is there any fix for this?

    Thank you Basheer for this wonderful tutorial!

    ReplyDelete
  5. i am getting

    Unsupported compiler 'GCC 4.2' selected for architecture 'i386'

    error

    ReplyDelete
  6. select your project ->Built Settings->compiler for C/C++/ objective -C(under bulit options)
    here change the option to default compiler (Apple LLMV compiler 4.1)

    ReplyDelete
  7. Camera does not start after build succeeds.. I followed every step.

    ReplyDelete
  8. Thanks for your tips, but it's difficult for me, if any have succeeded, hope he can share his resources with me: kenngreen89@gmail.com I need a such a QR Code reader for instagram.
    Any help will be appreciated.

    ReplyDelete

Post a Comment

Popular posts from this blog

Connect Samsung devices to Kies on Mac

Multiple line of text in UIPickerView