How to install ZXing in Xcode 4

How to install ZXing in Xcode 4

  • April 2011
  • Posted By Yannick Loriot

After an upgrading to Xcode 4, I have been having trouble compiling my own ZXing iOS project. That’s why I decided to explain you how to install easily ZXing with Xcode 4.

First of all (for those who don’t know), ZXing is an open-source library to read the 1D/2D barcodes. This library is available on many platforms such as the iOS, Android, Blackberry, ect. You can find it here:

Before to start, be sure that you have the latest version of ZXing on your computer. If you don’t, you must download it via a SVN client here:

To use ZXing into your project in Xcode 4 follow these steps:

  1. Firstly go to the “zxing/iphone/ZXingWidget/” and drag and drop the ZXingWidget.xcodeproj file onto your Xcode “Project navigator” sidebar. If a dialog appears uncheck the “Copy items” and verify that the “Reference Type” is “Relative to Project” before clicking “Add”.

  2. Now we are going to add ZXingWidget as a dependency of your project to allow Xcode to compile it whenever you compile the main project:
    1. First select your project file in the “Project navigator”.
    2. Then select the corresponding target.
    3. After choose the “Build Phases” tab and expand the “Target Dependencies” section.
    4. Click the “+” (add) button to display a dialog.
    5. To finish add the “ZXingWidget” target as shown above.

  3. Now we are going to link the ZXingWidget static library (libZXingWidget.a) to the project:
    1. Firstly choose the “Build Phases” tab and expand the “Link Binary With Libraries” section.
    2. Then click the “+” (add) button to display a dialog.
    3. To finish add the “libZXingWidget.a” which is located in the “Workspace” category as shown above.
    4. By the way add the following iOS frameworks too:
      • AddressBook
      • AddressBookUI
      • AudioToolbox
      • AVFoundation
      • CoreMedia
      • CoreVideo
      • libiconv.dylib

  4. Then you must configure the header search path of your project to allow Xcode to find the ZXingWidget headers. To do that:
    1. In the “Project navigator” select the main project (not the target).
    2. Go to the “Build Settings” tab and search the “Header Search Paths“.
    3. Double-click on it and add:
      • The full path of the “zxing/iphone/ZXingWidget/Classes” directory. Check the “recursive path“.
      • The full path of the “zxing/cpp/core/src/” directory. Uncheck the “recursive path“.

Now you just have to import the “ZXingWidgetController.h” and the “QRCodeReader.h” to your project and use them.
Attention: Make sure that the files in which you are using the ZXing headers have the .mm extension because they use c++ library files.

Voilà! Now all should be ok. I hope it’ll help you!

1 Star2 Stars3 Stars4 Stars5 Stars (36 votes, average: 4.56 out of 5)


Hi. I was having same problem as many: No such file or directory for the headers ZXingWidgetController.h and QRCodeReader.h. I solved the problem by adding the directories not only to "Header Search Paths" but also to "User Header Search Paths"! Cheers Liliana
hi i included zxing into my native application m getting the error like "Universalresult parser.h" file not can i remove these error pls help me
謝謝。 你的網頁,對我來說是很有幫助的。 Thank you. Your pages is helpful for me.
Well done. Nice tutorial. Works! Step 1 didn't show the mentioned dialog.
It took me a while to follow your instructions *correctly* :) When I did, it was a massive help. For my PhoneGap app, I also had to disable Automatic Reference Counting, remove the AudioUnit lib and add the AssetsLibrary lib to resolve compilation issues. I would not have figured this out without your excellent article, many thanks!
Worked like a charm for me. Thanks a lot for your post.
Hi, after all those steps, I have a iostream file missing :x Do you have any ideas why this error occurs now ?
Thanks for the tutorial! But on this line: #import "ZXingWidgetController.h" I get the error file not found... Do you know why there's this error? Cheers.
Please help me: I one error compilation libZXingWidget.a is red and I not found in the directory. ld: library not found for -lZXingWidget Command /Applications/ failed with exit code 1 Tnank you
@All thos who get #import “ZXingWidgetController.h” error file not found, Try to do the following:- 1) Download the SVN version of the code, not the zipped code. 2) Check if you have set an absolute path to your ZXingWidget project. 3) Make sure it is recursive (Append **, at the end) I got it working after doing these. Thanks for the tutorial. keep up the good work. Note: ZXing doesn't support Barcode scan yet. SO use it only for QRCodes.
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.
Hi, I installed ZXing in my project, but can not find examples to activate the camera and read a QR code. You know a URL? thanks
I have the same problem with James . I can not active the camera and read a QR code Could you help me ?
Thanks for your describtion! It helped me a lot!
I tried it several times but still same issue "ZXingWidgetController.h" file not found. I don't know what I am missing but I have followed each and every step. Tired...... Please help me
    aaahh! it was my mistake. there was an empty line automatically generated between Debug and Release in Header Search Path. I deleted that and it is working fine.. Thanks for the great tutorial.
      Hey can u help me! I am stragling with issue #import “ZXingWidgetController.h” file not found in my My App. How to over come with this?
#import “ZXingWidgetController.h” I get the error file not found… i have tried every thing on Header search Path. But i am not getting correct way to fix this issue
#import “ZXingWidgetController.h” I get the error file not found… i have tried every thing on Header search Path. But i am not getting correct way to fix this issue plz help
Hi, here's the solution behind #import “ZXingWidgetController.h” You need to verify the path of your files here's my example: My current project path: ~/Dropbox/Tesis Project/Celedex My current library ZXing: ~/Dropbox/Tesis Project/ZXingWidget So the header search paths look like this: ../ZXingWidget/Classes (recursive) ../../cpp/core/src (non-recursive) Good luck, and best wishes.
Guess what?, I'm using now ZBar it solved a lot of problems to me, if you want your app running with custom low-level features, and also a simple install process, go here: works fine for me, it's up to you. Btw, congrats on this post, it's awesome. Cheers.
What tutorial? People don't you read "READ ME" files included in the Zxing???? This is just a copy paste >:(
    Exactly, and this tutorial and even README won't work as it is now, I mean on newer xcode versions..
I want to copy ZxingWidget Static library in my project so that when i run on other system then i dont need any dependency to download and give path, Please tell me what steps i should follow
I am getting below error clang: error: no such file or directory: '/Users/alfa-1/Documents/Zxings/1/ZXingWidget/../../cpp/core/src/zxing/common/BitSource.cpp' clang: error: no input files Command /Applications/ failed with exit code 1
Thanks for the great explanation. I added header search path to the project not to the targets. I downloaded the zxing on the Desktop and used the following path : /Users/xyz/Desktop/zxing-master/iphone/ZXingWidget/Classes (Recursive) /Users/afsarkhan/Desktop/zxing-master/cpp/core/src (non-recursive) and follow other instructions correctly. But while going for the build for profiling option, getting the following error #import “zxing/common/Counted.h” // not found I am using Xcode version 4.3.1 and deployment target is set to 5.1. Is ZXing integration not allowed with this version? Could you please help me out in resolving this?

Leave a Reply

Your email address will not be published. Required fields are marked *