These are the basic instructions for obtaining the SDK and adding it to an Xcode project.
You may want to try things out with the ZBar SDK Integration Tutorial before hacking at your own project.
You will need all of the following to develop iPhone applications using this SDK:
Warning
Only the iPhone 3GS and iPhone 4 are supported, as they have a camera with auto-focus. The ZBar library does not support the iPhone 3G and is unlikely to ever support it.
Download the latest binary release of the ZBar SDK from
The recommended installation method is to simply copy the SDK into your Xcode project:
Open ZBarSDK-1.2.dmg in the Finder.
Drag the ZBarSDK folder into your Xcode project. In the dialog that appears, you should choose to copy the SDK into your project by checking the box. The target that you want to link with the library should also be selected in the target list.
Link the following additional frameworks to any targets that link with the ZBarSDK. You should set the first three to use weak references and configure an appropriate deployment target if you still need to support iOS 3:
If you check “Link Binary With Libraries” for the target(s), you should see all of these frameworks followed by libzbar.a.
Note
Link order may be important for some versions of Xcode; the referenced libraries should be listed before libzbar.a in the link order.
Import the SDK header from your prefix header to make the barcode reader APIs available:
#import "ZBarSDK.h"
Proceed to Scanning From the Camera Feed or Scanning a User-Selected Image to learn about using the reader APIs to scan barcodes. Use the API Reference for specific interface details.
If you are using an older version of the SDK (NB, skip to the next section if you are currently using Mercurial), upgrading is straightforward:
Clean out and rebuild your project with the new version.
If your project was using the library directly from the Mercurial repository, before the SDK was introduced, there are a few incompatibilities that you must resolve in order to upgrade. Don’t worry - all of your source stays the same, you just need to update how the library is included in the project and how the headers are imported.
This approach is recommended - the binary releases provide you with a stable development platform, isolating you from temporary instability and transient problems that may occur at the bleeding edge.
The first task is to reverse the previous ZBar integration:
Now just continue with the integration instructions above and you should be back up and running!
Alternatively, you may still prefer to select Mercurial revisions. You have a few choices for this:
In any case, you should remove the references to the zbar headers from prefix.pch (or your source files) and replace them with:
#import "ZBarSDK.h"