Monday, June 18, 2012

Integrate PhoneGap with Zxing for iOS - Barcode Scanner - Xcode 4

I spent a long time to config them. so tired, but now it run very good. It's work.

Step 1: 

Download Source PhoneGap at PhoneGap.com ( version 1.8.0 or higher )
after downloaded => install it and follow with introduction

Step 2: 

Download Source barcodescanner  at:
https://github.com/phonegap/phonegap-plugins/tree/master/iOS/BarcodeScanner



Step 3:


Integrate source from Step 2 to your project, follow with introduction (README)

Step 4:
Download zxing-2.0 SDK (search it in Google)

Step 5:

1. Locate the "ZXingWidget.xcodeproj" file under "`zxing/iphone/ZXingWidget/`". Drag ZXingWidget.xcodeproj and
drop it onto the root of your Xcode project's "Groups and Files" sidebar. A dialog will
appear -- make sure "Copy items" is unchecked and "Reference Type" is "Relative to Project"
before clicking "Add".

2. Now you need to link the ZXingWidget static library to your project. Click the "ZXingWidget.xcodeproj"
item that has just been added to the sidebar. Under the "Details" table, you will see a single
item: ZXingWidget.a. Check the checkbox on the far right of ZXingWidget.a.

3. Now you need to add ZXingWidget as a dependency of your project, so Xcode compiles it whenever
you compile your project. Expand the "Targets" section of the sidebar and double-click your
application's target. Under the "General" tab you will see a "Direct Dependencies" section.
Click the "+" button, select "ZXingWidget", and click "Add Target"


4. Headers search path 1: you need to tell your project where to find the ZXingWidget headers. Open your
"Project Settings" and go to the "Build" tab. Look for "Header Search Paths" and double-click
it. Add the relative path from your project's directory to the
"zxing/iphone/ZXingWidget/Classes" directory. Make sure you click the checkbox "recursive path" !
5. Headers search path 2: You need to add zxing ccp headers to your headers search path, do this similarly as previous step to point the path to cpp/core/src/ where the 'zxing' directory is. You don't need to make this search path recursive so do not check the "recursive path" option
6. Import the following iOS frameworks: AVFoundation, AudioToolbox, CoreVideo, CoreMedia and libiconv

7. You're almost ready to go ..


Step 6:
Open your source code , select ZXingWidget.xcodeproj choose Targets from SlideBar ( center ), in Architectures : you change armv6 to -DNS_BLOCK_ASSERTIONS=1



Step 7
Open Source Code, and select file: barcodescanner.js 
remove: 
if (Cordova.hasResource("barcodeScanner")) return
Cordova.addResource("barcodeScanner")
Step 7
RUN YOUR APPLICATION
HAVE FUN .
if you want to help, you can reply my post. 

No comments:

Post a Comment