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: http://code.google.com/p/zxing/.
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: http://zxing.googlecode.com/svn/trunk/.
To use ZXing into your project in Xcode 4 follow these steps:
- 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”.
- 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:
- First select your project file in the “Project navigator”.
- Then select the corresponding target.
- After choose the “Build Phases” tab and expand the “Target Dependencies” section.
- Click the “+” (add) button to display a dialog.
- To finish add the “ZXingWidget” target as shown above.
- Now we are going to link the ZXingWidget static library (libZXingWidget.a) to the project:
- Firstly choose the “Build Phases” tab and expand the “Link Binary With Libraries” section.
- Then click the “+” (add) button to display a dialog.
- To finish add the “libZXingWidget.a” which is located in the “Workspace” category as shown above.
- By the way add the following iOS frameworks too:
- AddressBook
- AddressBookUI
- AudioToolbox
- AVFoundation
- CoreMedia
- CoreVideo
- libiconv.dylib
- Then you must configure the header search path of your project to allow Xcode to find the ZXingWidget headers. To do that:
- In the “Project navigator” select the main project (not the target).
- Go to the “Build Settings” tab and search the “Header Search Paths“.
- 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!
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 found….how 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 😡
Do you have any ideas why this error occurs now ?
Is this answer on stackoverflow helps you?
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/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang 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: http://zbar.sourceforge.net/iphone/sdkdoc/install.html 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..
http://stackoverflow.com/questions/12968369/undefined-symbols-for-architecture-armv7-when-using-zxing-library-in-xcode-4-5
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/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang 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?