ZXing iPhone/iPad README
ZXing for iOS is a sub-project of zxing project partially maintained by independent developers. As of 26th of March 2011, it contains 3 iOS projects:
- Barcodes: Zxing iOS app. Available on the app store.
- ZXingWidget: a Library that can be included in any iOS app.
- ScanTest: a simple demo app for ZXingWidget.
How to include ZXingWidget in a easy and clean way (in Xcode4)
ZXingWidget.xcodeprojand drop it onto the root of your Xcode project sidebar. A dialog will appear — make sure Copy items is unchecked and Reference Type is Relative to Project before clicking Add. Alternatively you can right-click on you project navigator and select 'Add files to your project'.
Now you need to link the ZXingWidget static library to your project. To do that
a. select you project file in the project navigator
b. In the second column, select your target (not the project itself)
c. Go to the Build Phases tab, expand the Link Binary with Libraries section
d. Click the Add button. A dialog will appear and you should see
libZXingWidget.aat or near the top of the list
Now you need to add ZXingWidget as a dependency of your project, so Xcode compiles it whenever you compile your project.
a. Like in substep c of previous step, you need to do that in the Build Phases tab of your target
b. Expand the Target Dependencies section
c. Click the Add button and a dialog will appear. Select
ZXingWidgetto the Headers Search Path.
a. Select your project in the project navigator and then select your target.
b. Go to the Build Settings tab, look for Header Search Paths and double-click it.
c: Add the relative path from your project's directory to the
zxing/iphone/ZXingWidget/Classesdirectory and select the Recursive Path checkbox.
Add the C++ core to the Headers Search Path. Repeat step 5, but add the path to the C++ core:
zxing/cpp/core/src. Do not select the Recursive Path checkbox.
Import the following iOS frameworks:
This must be done by adding them in the Link Libraries with Binary just like step 2.c. If you are supporting iOS 4, for AVFoundation, you must select Optional in the pull down to the right in order to weak link the framework. (Some symbols used in ZXing didn't exist before iOS 5.)
#import <ZXingWidgetController.h>in a source file
#import <MultiFormatReader.h>for example because you will need to inject a barcode reader into
Make sure the file in which you are importing the code headers has a
.mmextension to enable importing C++.
main.mmto link against the C++ standard library.
Make sure the C++ library in Build Settings is Compiler Default. Some versions of Xcode set this to the LLVM standard library. Alternately, you can try setting the C++ library to the LLVM version int the
XingWidgetproject but this is not well-tested.
Known issues for above steps to include:
- If you have building error like " ... : No such file or directory", then it is a classical error, it means that the include path is not well specified. The best way to fix this is to look at the build command that failed. To do that, click on the lower right corner of your Xcode project, you should see the build command that failed. Click on it and expand it by clicking on the more symbols that just appeared. This will show the exact command line instruction that failed. You can then make sure that the header search path you specified is there, and you can also copy/paste this line into your terminal and try to see if you can reproduce/fix the error by adding the right path to the compiler. Once is is fixed, you should have an idea of what's the problem and accordingly modify your Header Search Path.