Wednesday, July 20, 2011

QR Code reader/scanner for iphone app in objective c (source code) using ZBarSDK

Hey, I have googled a lot and found very less material for how to implement a QR code reader in our iPhone app. Here I have integrated all material and implemented in my project.
So here I am sharing my experience of implementing a QR code reader in our iPhone app using ZBarSDK.


Step 1: Download  ZBarSDK from here.


Step 2: Create a new project in xcode and name it as QRscanner.


Step 3: Integrate this  ZBarSDK folder in your xcode project by drag and drop on equal level of class folder in left panel in xcode.


Step 4: Add these 7 frameworks in Frameworks folder: 

  1. AudioToolbox.framework
  2. CoreMedia.framework
  3. QuartzCore.framework
  4. SystemConfiguration.framework
  5. libiconv.dylib
  6. AVFoundation.framework
  7. CoreVideo.framework

Step 5: Now Go To this link and generate some QR codes.
(to generate QR codes only add the text which you want to attach with QR code at the end of the link (e.g. I have written archana) and press enter, and right click to save this image.) 


Step 6: Add these generated QR code's image in iphone library.


Step 7: Now open QRscannerViewController.h in your xcode and write this code:


#import <UIKit/UIKit.h>
#import "ZBarSDK.h"

@interface QRscannerViewController : UIViewController <UIImagePickerControllerDelegate,ZBarReaderDelegate>{

IBOutlet UITextView *resultTextView;
}
@property (nonatomic, retain) IBOutlet UITextView *resultTextView;
@property (nonatomic, retain) UIImagePickerController *imgPicker;

-(IBAction)StartScan:(id) sender;

@end

Step 8: Now open QRscannerViewController.m in your xcode and write this code:





#import "QRscannerViewController.h"

@implementation QRscannerViewController

@synthesize imgPicker,resultTextView;

-(IBAction)StartScan:(id) sender
{
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.readerView.torchMode = 0;
ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here
// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology: ZBAR_I25
  config: ZBAR_CFG_ENABLE
  to: 0];
// present and release the controller
[self presentModalViewController: reader
animated: YES];
[reader release];
resultTextView.hidden=NO;
}

- (void) readerControllerDidFailToRead: (ZBarReaderController*) reader
                             withRetry: (BOOL) retry{
NSLog(@"the image picker failing to read");
}

- (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info
{
NSLog(@"the image picker is calling successfully %@",info);
// ADD: get the decode results
id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
NSString *hiddenData;
for(symbol in results)
hiddenData=[NSString stringWithString:symbol.data];
NSLog(@"the symbols  is the following %@",symbol.data);
// EXAMPLE: just grab the first barcode
//  break;
// EXAMPLE: do something useful with the barcode data
//resultText.text = symbol.data;
resultTextView.text=symbol.data;
NSLog(@"BARCODE= %@",symbol.data);
NSUserDefaults *storeData=[NSUserDefaults standardUserDefaults];
[storeData setObject:hiddenData forKey:@"CONSUMERID"];
NSLog(@"SYMBOL : %@",hiddenData);
resultTextView.text=hiddenData;
[reader dismissModalViewControllerAnimated: NO];
}


Step 9: Now open QRscannerViewController.xib and design it UI like this:






Step 10: Now make connection of above 2 objects(UITextView and UIButton) with IBOutlet resultTextView and IBAction StartScan.(Refer Step 7 of…) 


At last build and run this app.


How to run this app:


Press  "START SCAN" button, and as we are running our app in simulator you will get screen like this:






Now press and hold (alt key)+(left click), Photo Album (image gallery, photo library) will open.
Select any QR code image. It will take hardly 2-3 seconds for scanning and finally you will get home screen with scanned data associated with QR code image on text view.


Download source code from here.

117 comments:

  1. Great stuff, seriously helped me out. But does this actually use the camera outside of the simulator or is this only for a demo with a picker?

    ReplyDelete
  2. @DrLove: Thanks!!! This will also use camera when you will install this app on device, once test on device, all things will be clear.

    ReplyDelete
  3. This is awesome!
    Thank you for sharing. It's really helpful :)

    ReplyDelete
  4. @Phyllis: Thank you !!! I like to share my experiences :)

    ReplyDelete
  5. excuse me, an 'information.
    I have been following the tutorial and the application works, just that I have a problem.
    After the scan the QR code as output I get the link contained within, for example, whether stored in the QR Code is a link to a video, I don't play the video, but the link returns.
    What should I do to play the video, or an image or an mp3?
    PS: Sorry for my bad English

    ReplyDelete
  6. @Andrea: If you want to play the video associated with link then just right the code for playing a video in this delegate method - (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: and give the path for video file that link which you have got after scanning.
    If any confusion feel free to write here.

    ReplyDelete
  7. Hi, I have a problem integrating the ZBarSDk into my project. The build failed and these 2 errors were returned:

    "_OBJC_CLASS_$_ZBarReaderViewController", referenced from:
    objc-class-ref-to-ZBarReaderViewController in QRscannerViewController.o

    "_ZBarReaderControllerResults", referenced from:
    _ZBarReaderControllerResults$non_lazy_ptr in QRscannerViewController.o

    I have already followed the steps by importing "ZBarSDK.h" in the .h file. Please help! Thank you!

    ReplyDelete
  8. I've solved the issue. Thanks for your guide by the way! :)

    As mentioned here: http://zbar.sourceforge.net/iphone/sdkdoc/tutorial.html, the frameworks need to be included in the specified sequence.

    The package from eSnips (as stated above) also does not include libzbar.a

    libzbar.a can be obtained from the original ZBarSDK here: http://zbar.sourceforge.net/iphone

    ReplyDelete
  9. Hi,

    Im having a slight problem... when i select the image from my gallery, it shows me the image in the app simulator with a window with a "Cancel" and "info" button on the toolbar docked at the bottom.

    Now nothing happens. The image doesn't scan, no results are displayed, nothing. Is there supposed to be a button to press to deploy the image or something that I'm missing ???

    As of now I just hit cancel after like 5 mins and then go back to the previous screen

    ReplyDelete
  10. @sasha172: If I got your point then for that you have to Press (Alt button + left mouse click) and hold it. It will navigate you to photo gallery of simulator. Is it your solution ?

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. Hi,
    It chose image from the photo gallery, but it not take the out put of the respected qr code

    ReplyDelete
  13. @gogoi : what ever you want to do after taking the image, do write that in this method - (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info

    ReplyDelete
  14. Hi

    For reading a QR Code Stored in Phone Library, what all lines we have to modify in below link.
    It is taking the image from Photo library but no such output is coming



    - (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info
    {
    NSLog(@"the image picker is calling successfully %@",info);
    // ADD: get the decode results
    id results = [info objectForKey: ZBarReaderControllerResults];
    ZBarSymbol *symbol = nil;
    NSString *hiddenData;
    for(symbol in results)
    hiddenData=[NSString stringWithString:symbol.data];
    NSLog(@"the symbols is the following %@",symbol.data);
    // EXAMPLE: just grab the first barcode
    // break;
    // EXAMPLE: do something useful with the barcode data
    //resultText.text = symbol.data;
    resultTextView.text=symbol.data;

    ReplyDelete
  15. @swati: Here i have written my own code for printing the hidden data in QR code on consol. But you can write your code for what do you want after scanning.

    ReplyDelete
  16. Hi

    I wanted the hidden QRCode data flash in a text field of an iPhone.Is it possible with the code mentioned above.


    we can't download the source code.
    please do tell send me another link.

    ReplyDelete
  17. @swati: yes it is possible by above code. Run app and see on consol.

    ReplyDelete
  18. @swati: The code is downloadable. Just now I have downloaded it.

    ReplyDelete
  19. This comment has been removed by the author.

    ReplyDelete
  20. @swati: Check your mail. I have sent it.

    ReplyDelete
  21. Hi Archana,

    Thanks a lot for your co-operation and patience to reply.
    Yes i got mail.

    One more thing want to clear
    Will this application work for ipad application also.
    I tried with ipad application and nothing is displaying.
    Can you please put some light on this issue.

    ReplyDelete
  22. HI archana......
    Can u plz send source code to dis mail id pavuluri.anu81@gmail.com

    ReplyDelete
  23. Hi,
    I have same doubt as swati, please let me know whether it is possible or not .
    i am also trying same with ipad simulator.

    Thanks in advance

    ReplyDelete
  24. @anusha: source code is already attached in this post "Download source code from here" written in this post.

    ReplyDelete
  25. Hi,

    Thanks for this great post! Do you know how to remove the info button? We could use the showControls = No but this would hide the cancel button. It looks like we could add our custom button via the overlay function, but I'm not sure how to do that. Any help would be appreciated.

    Thanks
    Martin

    ReplyDelete
  26. @Mart Coul: Thanks !!! I can help you if you will be more descriptive like What info button you are talking about ? Please describe your problem here.

    ReplyDelete
  27. @Archana - Thanks for the feedback. When you are in scanning mode, at the bottom there is a toolbar with a cancel button on the left and an info button on the right. I'd like that specific button to be removed. Would you have an idea on the best approach to do that? I would not want to lose the cancel button which is what happens if I put "showControls = No".

    Thanks a lot!

    ReplyDelete
  28. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. @Mart Coul: Ok, I got your issue. Actually those are ZBar Controls, So in your code where you are creating the object of ZBarReaderViewController, set the property showsZBarControls as FALSE.
      For example in my code:
      ZBarReaderViewController *reader = [ZBarReaderViewController new];
      reader.showsZBarControls = FALSE;

      By writing this both buttons (cancel and info) will be remove and there you can draw your own custom button. Because we can't modify the ZBar SDK files.

      Delete
    2. Thanks Archana! Yes putting the showsZBarControls = FALSE does work to remove both buttons. But I'm unsure how to add a custom button on that scanning screen. I do add buttons in my others screen and I know how, but I'm not sure how to do it for this one since the ZBar SDK manage that screen. Do you have a sample code for this for me to look at? I've looked on google and could not find an example.

      Thanks!

      Delete
  29. @Mart Coul: For adding custom button on scanning screen, create a button in normal way and then where you are writing reader.showsZBarControls = FALSE;
    write this also: reader.cameraOverlayView = (UIView *)myCustomButton;

    ReplyDelete
    Replies
    1. Thanks a lot Archana! It is working very well!!!! Have a good week end!

      Martin

      Delete
    2. Archana Chaurasia, I did the same that Mart Coul, but it dosn't work for me, can you please show an example of it? Thank you very much

      Delete
  30. I am having a problem with this implementation. I followed the directions step by step but I am getting the following error:

    clang: error: unable to execute command: Segmentation fault: 11
    clang: error: linker command failed due to signal (use -v to see invocation)

    I have tried searching everywhere that I can find. Does anyone have any idea what the problem could be. I am running XCode 4.4 DP2 and iOS 5.1 trying to run with the simulator and my iPhone 4S. I cannot even get the app to compile

    ReplyDelete
  31. @Archana, thank you so much for sharing this. It works great.

    I have the same problem as @Mart Coul described, but I can't get it to work. The default buttons are removed, but I can not add my own. Any help would be much appreciated

    I've done this:

    //remove the default ZBar controls as we will implement our own
    reader.showsZBarControls = NO;

    //implement our own cancel button
    UIButton* backButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [backButton setTag:301];
    [backButton addTarget:self action:@selector(scannerButtonTapped:) forControlEvents:UIControlEventTouchUpInside];

    reader.cameraOverlayView = (UIView *)backButton;

    Cheers,
    Vedran

    ReplyDelete
  32. Hey man! Great code, really helpful!

    Will this work with opening up URL links?

    Thanks,

    ReplyDelete
  33. @Archana

    I have figured out the implementation to URLs. This app and source code works great. However, I am having trouble implementing this to the iPad. Would you happen to know how to deal with this?

    Thanks

    ReplyDelete
  34. @Shamsuddin Bhuiyan: Thanks ! and I have also implement it in ipad, and it worked fine. If you have any trouble you share it here and we can figure out it.

    ReplyDelete
    Replies
    1. @Archana : I tried implementing this in my universal iOS application and everything went ok until I tried to scan a Page using iPad 3 Camera. The view seems to take only 1/4 of the entire screen of the iPad.
      I tried a lot to sort it myself, but failed. Could you please explain how you obtained the same in iPad.

      Delete
  35. @Archana

    I am now a follower of your site. Its a great source for someone who is just learning how to do iOS development.

    Anyways, whenever I attempt to run it on the iPad simulator, I get this error output:


    2012-05-09 17:16:55.046 QRscanner[1176:10703] UIStatusBarStyleBlackTranslucent is not available on this device.

    2012-05-09 17:16:55.049 QRscanner[1176:10703] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'On iPad, UIImagePickerController must be presented via UIPopoverController'

    I cannot, for the life of me, figure out what is amiss.

    ReplyDelete
  36. @Archana

    Looks like it actually works fine in an actual iPad but not on the simulator. Just ran and tested it. Works great. If I wanted to change the dimensions of the scanner, what would I do?

    ReplyDelete
  37. @Archana

    Will you please guide on bar code scanner in same way..
    thank you very much

    ReplyDelete
  38. works fine with qr code that you have given with source code. But doesn't work for other qr codes. It doesn't focus properly.

    ReplyDelete
  39. @Ajit Satarkar: It also scans bar code.

    ReplyDelete
  40. Hi , I want to know how to add images to the album ?

    I tried this path to put the image "/Users/user/Library/Application Support/iPhone Simulator/5.1/Media/PhotoData/AlbumsMetadata" , but no use.

    ReplyDelete
  41. @范凱傑: Check my this post to add photos in image gallay: http://iphonenativeapp.blogspot.in/2011/07/add-images-to-iphone-photo-gallery.html

    ReplyDelete
  42. Hi ,

    I have a problem again , now I can add image to the photo album ,
    and follow your steps to decode , but after I choose my QR-image , the screen just show my QR-image , it does not decode the QR-image .

    ReplyDelete
  43. Oh ! it should choose the image twice , but I don't know why , lol

    ReplyDelete
  44. @ 范凱傑 If my post was helpful for you then join my blog and also you can left the comment on my this post http://iphonenativeapp.blogspot.in/2011/07/add-images-to-iphone-photo-gallery.html

    ReplyDelete
  45. Hi Archana,

    I have a problem. After loading the QR code from the library nothing is shown. Can you please let me know if I am doing something wrong. And also the QR code generated is the mirror image. Your help will be appreciated.

    Regards,
    Lokesh

    ReplyDelete
  46. Hi Archana,

    I resolved the issue. Actually the QR code generated was not at the center. I created a new QR code and the app is working perfectly. Many thanks for such nice tutorial.

    Regards,
    Lokesh

    ReplyDelete
  47. Thanks a lot.. I am following now and hope to learn a lot of things.. Have a great day :)

    ReplyDelete
  48. Hi, I have a problem with your code. I have 3 errors.
    Undefined symbols for architecture i386:
    "_OBJC_CLASS_$_ZBarReaderViewController", referenced from:
    objc-class-ref in ViewController.o
    "_ZBarReaderControllerResults", referenced from:
    -[ViewController imagePickerController:didFinishPickingMediaWithInfo:] in ViewController.o
    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    why, i don't understand, I am new

    ReplyDelete
  49. Hi Archana,
    I am sorry to post a question here as i dont know where to post the same.

    I need your help. Can you please let me know how to create a grid view like Google Play in iPhone.

    Your help is much appreciated

    Regards,
    Lokesh

    ReplyDelete
  50. Hi Archana, I am not able to download your code it says link broken. I tried using your steps but my imagePickerController:didFinishPickingMediaWithInfo method is not getting called. Can you mail the code to sonuengineer@gmail.com asap. I am in urgent need. Thanks

    ReplyDelete
  51. @Sanjay Kumar: From my side its working fine, I am able to dounload, but still I am sending you the code on your ID.

    ReplyDelete
  52. Archana, first off, a BIG thank you for helping us out. You are such a good teacher!

    I'd greatly appreciate it if you can help me with my problem, although the others above had the same problem, it is not working for me.

    I tried adding a button on my scanning screen, the cameraOverlay screen, but the button shows up on my main screen, the view controller. I have absolutely no idea how to put a button on the camera scanning screen even though I can do it on anything with a .h or .m file. Where do we even implement code for camera scanning screen?


    here's my problem.


    I implemented this in my viewcontroller.h file:
    __________________________________________________


    @interface SecondViewController : UIViewController

    < ZBarReaderDelegate >

    {
    UIButton *btnButton;
    }
    ____________________________________________


    Then I implemented this for an overlay(in case u need to c):
    __________________________________________________
    - (UIView*)CommomOverlay {

    UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,480)];

    UIImageView *FrameImg = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)];

    [FrameImg setImage:[UIImage imageNamed:@"newGraphicOverlay.png"]];

    [view addSubview:FrameImg];

    return view;

    }

    _______________________________________________


    Then I put this in my viewcontroller.m file as
    -(IBAction) scanButtonTapped {



    // ADD: present a barcode reader that scans from the camera feed

    ZBarReaderViewController *reader = [ZBarReaderViewController new];

    reader.readerDelegate = self;


    reader.supportedOrientationsMask = ZBarOrientationMask(UIInterfaceOrientationPortrait);


    ZBarImageScanner *scanner = reader.scanner;

    reader.showsZBarControls = YES;

    reader.cameraOverlayView = (UIView *)btnButton;

    UIButton *btnButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];

    [btnButton addTarget:self action:@selector(btnButtonTapped:)forControlEvents:UIControlEventTouchDown];

    [btnButton setTitle:@"Show View" forState:UIControlStateNormal];

    btnButton.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);

    [self CommomOverlay];

    [self.view addSubview:btnButton];

    [scanner setSymbology: ZBAR_UPCE

    config: ZBAR_CFG_ENABLE
    to: 1];



    [self presentModalViewController: reader

    animated: YES];



    reader.cameraOverlayView = [self CommomOverlay];

    [reader release];

    }


    ___________________________________________________




    As you can see I made the button in the scanButtonTapped because only after the scan button is tapped the second view appears, which is the scanning screen/ overlay screen.



    But the button shows up only on the first screen( the screen controlled by the viewcontroller.m and viewcontroller.h).


    I don't want the button on the screen which has the scan button though. How do I make sure the button goes on the scanning screen?


    Please help as soon as you can, for I'd be greatly indebted to you! I'd also appreciate it if you can provide detailed instructions. Thanks so much in advance!

    ReplyDelete
  53. Hi Archana,really g8 work .I love this blog and there is lot of material to learn.Gud job!!!!!!

    ReplyDelete
  54. @Unknown : Thanks a lot, I am trying to make it more lovable :)

    ReplyDelete
  55. Hi,

    My image picker controller function is not being called. Can you please tell me why?

    ReplyDelete
  56. This comment has been removed by the author.

    ReplyDelete
  57. i m running this code on simulator , i'm select the image from the photo library , but after that

    - (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info , method is not called ...

    ReplyDelete
  58. Replies
    1. @Danny Alexander Alva Rojas : Follow the step 5. Actually there are many way to create QR codes, one of then I mentioned in Step 5.

      Delete
  59. Its as if you read my thoughts about iPad Developer You appear to understand a great deal relating to this, as if you authored it inside it or something like that. I believe you could use a couple of photos they are driving the content home a little, but apart from that, this really is great blog. An excellent read. I'll certainly return.

    ReplyDelete
  60. hey archana , can u tell me how to create this application for a compnay qr code reader ...

    send me details on lgaksh@yahoo.com

    thanks 4 urs support

    ReplyDelete
    Replies
    1. @aakash: This will work for scanning any type of QR codes. So no need to create a different application for a company QR code.

      Delete
  61. Can we fetch image from library instead of camera, so that we can test it on simulator.
    Please guide me, if it is possible. Thanks in advance.

    ReplyDelete
  62. Please reply to randeep.stpl@gmail.com and also tell me the way to download this code.
    Thanks.

    ReplyDelete
    Replies
    1. @Randeep Singh : Yes you can pick the image from library by setting the source of image picker as we will set : UIImagePickerControllerSourceTypePhotoLibrary OR UIImagePickerControllerSourceTypeSavedPhotosAlbum.
      As mention below:
      imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary
      imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum

      Delete
    2. Archana mam please tell how can i do this.

      Delete
  63. Thank u mam, but i wanted to ask whereto change it.

    -(IBAction)scan
    {
    imagePickerController = [[UIImagePickerController alloc] init];
    imagePickerController.delegate = self;
    imagePickerController.allowsEditing = YES;
    imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    [self presentModalViewController:imagePickerController animated:YES];

    [imagePickerController release];
    // [alert dismissWithClickedButtonIndex:0 animated:YES];
    NSLog(@"Gallery");
    }

    -(void)imagePickerController:(UIImagePickerController *)reader didFinishPickingMediaWithInfo:(NSDictionary *)info
    {

    [self scanCode];

    image1 = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    imageView.image=image1;

    [self dismissModalViewControllerAnimated:YES];

    NSLog(@"the image picker is calling successfully %@",info);
    // ADD: get the decode results

    id results = [info objectForKey: ZBarReaderControllerResults];
    NSLog(@" results:%@", results);
    ZBarSymbol *symbol = nil;
    NSString *hiddenData;
    for(symbol in results)
    hiddenData=[NSString stringWithString:symbol.data];
    NSLog(@"the symbols is the following %@",symbol.data);
    // EXAMPLE: just grab the first barcode
    // break;

    // EXAMPLE: do something useful with the barcode data
    //resultText.text = symbol.data;
    //resultTextView.text=symbol.data;


    NSLog(@"BARCODE= %@",symbol.data);

    NSUserDefaults *storeData=[NSUserDefaults standardUserDefaults];
    [storeData setObject:hiddenData forKey:@"CONSUMERID"];
    NSLog(@"SYMBOL : %@",hiddenData);
    result.text=hiddenData;
    [reader dismissModalViewControllerAnimated: NO];
    }


    I did this way, but the results(id) shows null.

    Please tell where i am getting wrong.

    ReplyDelete
    Replies
    1. Then you have to check the image which you are scanning. I that image is a correct QR code or just a normal image.

      Delete
    2. [self scanCode]; what is this method contain can you send the code

      Delete
  64. @Archana: Hii.. if, you can please send me the code to my mail id:(rswalia1985@gmail.com), it is not downloading here. And please tell me that where i need to put that code(fetch image from library) in your code or the Zbar sdk. Please guide me if you can and i am thankful to you for your till cooperation.

    ReplyDelete
  65. I am having problem similar to some others. I am using 4.5 and can get the events to occur as predicted. I create QR Codes, save them to Photo Library, Load them in, but nothing occurs after that. The program simply stalls. And....the images are being scaled larger that the viewport. I even size them down to below 500x500 but inside the QRScanner, they appear scaled up 2-3 times that. HELP!

    ReplyDelete
  66. I'm having a problem with the Delegate not being called once the reader gets focus. Could you send the source code to me? I'm unable to download it from the linked page.

    lemmings@gmail.com

    Thanks!

    ReplyDelete
  67. Hi Archana,

    I need help in creating a excel file from sql data. Can I get some help from you if you have any knowledge about this.

    Regards,
    Lokesh

    ReplyDelete
  68. The content is good and very informative and I personally thank you for sharing the iphone and qr code articles.

    Barcode Networking

    ReplyDelete
  69. I have followed every word in the tutorial above, the only line of code i remove is [reader release]; as it was generating error in my iOS 6 simulator. Now, the problem is the app works until when it loads the image, then it doesnt display the results of the QR code. Any help? Much appreciated

    ReplyDelete
  70. Thanks for sharing your knowledge Archana!

    If I run the program in iPhone Simulator, it runs perfectly fine. But when I try to run it on Ipod 4g, I get the following error:


    Apple Mach-O Linker Error

    Ld /Users/ .... /ZBarSDKImplementation-gwadphibgtfgvmabhleptfjbxqwc/Build/Intermediates/ZBarSDKImplementation.build/Debug-iphoneos/ZBarSDKImplementation.build/Objects-normal/armv7s/ZBarSDKImplementation normal armv7s
    cd "/Users/.../ZBarSDKImplementation"
    setenv IPHONEOS_DEPLOYMENT_TARGET 5.1
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -L/Users/..../Xcode/DerivedData/ZBarSDKImplementation-gwadphibgtfgvmabhleptfjbxqwc/Build/Products/Debug-iphoneos "-L/Users/..../ZBarSDKImplementation/ZBarSDKImplementation/ZBarSDK" -F/Users/... /Xcode/DerivedData/ZBarSDKImplementation-gwadphibgtfgvmabhleptfjbxqwc/Build/Products/Debug-iphoneos -filelist /Users/..../Xcode/DerivedData/ZBarSDKImplementation-gwadphibgtfgvmabhleptfjbxqwc/Build/Intermediates/ZBarSDKImplementation.build/Debug-iphoneos/ZBarSDKImplementation.build/Objects-normal/armv7s/ZBarSDKImplementation.LinkFileList -dead_strip -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=5.1 -liconv -framework QuartzCore -framework CoreVideo -framework CoreMedia -framework AVFoundation -framework UIKit -framework Foundation -framework CoreGraphics -lzbar -o /Users/.../Developer/Xcode/DerivedData/ZBarSDKImplementation-gwadphibgtfgvmabhleptfjbxqwc/Build/Intermediates/ZBarSDKImplementation.build/Debug-iphoneos/ZBarSDKImplementation.build/Objects-normal/armv7s/ZBarSDKImplementation

    ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/.../ZBarSDKImplementation/ZBarSDKImplementation/ZBarSDK/libzbar.a for architecture armv7s
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    FYI...I am using ZBarSDK 1.2 and I am following to the documentation on: http://zbar.sourceforge.net/iphone/sdkdoc/ in order to make a working app to scan QR codes. I am using Xcode 4.5 to write the code.

    Despite the fact that I go though the steps religiously, I run into the above mentioned error.


    Also, I am not able to download your source code. Can you please check the link?

    Thanks!

    ReplyDelete
  71. Dear Archana Chaurasia, thanks for sharing your knowledge and your blog.

    I am facing some problem after integrating ZBarframework for scanning QRCodeRead on my apps. My client wants, QRCode Scanner will be in a fixed frame and must not be a PresentModalView. Then I write code for fixed frame QRCode Scanner and adding reader.view on self.view, but it not working as presentModalViewController:reader. I don't know what is my fault and can't solve this problem. I provide my code bellow and Sorry for my bad English.

    *After integrating this code working fine.
    - (IBAction) scanButtonTapped
    {
    ZBarReaderViewController *reader = [ZBarReaderViewController new];
    reader.readerDelegate = self;
    reader.supportedOrientationsMask = ZBarOrientationMaskAll;

    ZBarImageScanner *scanner = reader.scanner;
    [scanner setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:0];

    [self presentModalViewController:reader animated:YES];
    [reader release];

    * But this code not working, just showing a green box which focus QRCode but doing nothing.

    - (IBAction) scanButtonTapped
    {
    ZBarReaderViewController *reader = [ZBarReaderViewController new];
    reader.readerDelegate = self;
    reader.supportedOrientationsMask = ZBarOrientationMaskAll;
    reader.showsCameraControls = NO;
    reader.showsZBarControls = NO;
    [reader setWantsFullScreenLayout:NO];
    reader.showsHelpOnFail = NO;
    reader.showsZBarControls = NO;
    [reader.view setFrame:CGRectMake(20, 134, 280, 202)];

    ZBarImageScanner *scanner = reader.scanner;
    [scanner setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:0];

    [self.view addSubview:reader.view];
    [reader release];
    }

    Please help me and give me a solve to get out from here...thanks at advance...

    Have a good day!

    ReplyDelete
  72. hello Archana..... its not working for other qrcode..... and also not working for second time of same qrcode.... can u plz help me yaar.....

    ReplyDelete
  73. hello archana.... not working for other qrcode..... and not working for second time for u given qrcode... can u help me plz....

    ReplyDelete
  74. Please send code to this mail sk.ijaz@gmai.com

    ReplyDelete
  75. This does not seem to work in simulator .. ? I havent tested this on the device .But doesnt seem to work on the simulator.

    ReplyDelete
  76. Hi,
    I m using zbarsdk to scann barcode, its working good,but after alert of upc code how to use it in app to proceed further

    thanks

    ReplyDelete
  77. nice tutorial .
    Thanks

    ReplyDelete
  78. Thank you a lot!! Archana.. for your time.

    I used Zxing lib for scanning QR code, was looking for ZBar, I found your tutorial is straightforward, going to give it a shot this morning!! and let you know.

    I do share my knowledge as well, you may like to have look at here "http://www.rdcworld-iphone.blogspot.in"

    Please! keep sharing this. be social :)

    Regards,
    RDC

    ReplyDelete
  79. I found one issue, not very important, but maybe could be easily fixed. When I check the option to automatically reconnect, and phone BT is turned off, or phone is taken away from the tablet and there is no connection, tablet power consumption is quite high
    i phones

    ReplyDelete
  80. Hi Archana,
    The example given is simple and straightforward.I tried with the steps but i Guess my didFinishPickingMediaWithInfo is not get called,Can you please mail the source code as am unable to download from the Link provided

    ReplyDelete
  81. could you please send the working code to mail id datchayan.sp@gamil.com.

    ReplyDelete
  82. Hi arachana , could you please explain how to scan the QR code in device

    ReplyDelete
  83. Please send demo to this mail anovoselskiy@alteso.com

    ReplyDelete
  84. This comment has been removed by the author.

    ReplyDelete
  85. Hi,
    I am using z bar SDK for iphone to scan QR code ,by default scanning camera is back camera but I want scan QR code from rear camera so how can enable rear camera of iphone using Zbar SDK version 1.2.

    ReplyDelete
  86. Archu you rock !!! great work....

    ReplyDelete
  87. hi archana,
    everything is fine but i selected the image from library. App is not working.
    And also i got this error "linker command failed with exit code 1 (use -v to see invocation)" when i tried to install application in device.Please send me the code to my mail (naveen.medeti@gmail.com)

    ReplyDelete
  88. buy cheap smartphones project by drag and drop on equal level of class folder in left panel in xcode.

    ReplyDelete
  89. hi this is my code
    id results =
    [info objectForKey: ZBarReaderControllerResults];
    DLog(@"4");
    ZBarSymbol *symbol = nil;
    for(symbol in results)
    {
    isAnyBarcodeScanned=YES;
    overlay.btnCode.enabled=TRUE;

    if ([symbol.data isEqualToString:@""])
    {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure" message:[FSM_COMMON_SETTINGS returnMessageForCode:89162] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
    [alert show];

    return;
    }

    in above code i sometimes get symbol.data as @"". Do you know why it must be happening?

    ReplyDelete
  90. Nice post. So helpful idea. Thanks for sharing. en ucuz iphone 5

    ReplyDelete
  91. Hi,
    It chose image from the photo gallery, but it not take the out put of the respected qr code

    ReplyDelete
  92. hi archana,
    everything is fine but i selected the image from library. App is not working.
    And also i got this error "linker command failed with exit code 1 (use -v to see invocation)" when i tried to install application in device.Please send me the code to my mail (saritbahuguna74@gmail.com)


    please mam help me....

    ReplyDelete
  93. In case your QR code images zoom in, here's a code snippet you can add inside (IBAction) scanButtonTapped:

    reader.readerView.zoom = 1.0;

    Got it from another article about creating a barcode scanner, here's the link:

    http://wallmobile.wordpress.com/2013/06/19/how-to-add-zbar-sdk-in-xcode-for-qrcode-scanner-barcode-scanner/

    Archana, thanks a lot for this tutorial, it is indeed very helpful. I was able to test the ZBar SDK on XCode. I need to use a mouse for the alt + left click buttons for getting an image from the Photo Library. Your tutorial in adding an image to the Photo Library is also very helpful.

    Keep up your tutorials.

    ReplyDelete
  94. I Can't download the project from the link
    Will u please send the project to teddythms@gmail.com

    ReplyDelete
  95. Hi there,

    I can not download the SDK either. Can you please advice?

    Johan

    ReplyDelete
  96. Nice post with great details. I really appreciate your idea. Thanks for sharing.
    -----------------------------------------------------------------
    iPhone 5 App Development & iPad Application Developer

    ReplyDelete
  97. We have huge information about iPhone & iPad Apps. Do you wanna develop your mobile Apps? come check out our website, http://www.taoteapps.com, we have a lot information to help making your mobile deployment a success.

    ReplyDelete
  98. The interest for iphone and other cell phone provision improvement administrations proceeds to develop. As clients encounter the different profits of utilizing versatile applications, they will start to depend on these applications for an assembly of things like for getting data about their most loved motion pictures, entering markdown coupons from grocery store stores, downloading music and for playing recreations.
    iPhone App Builder // Mobile Application Development // iPhone Application Development

    ReplyDelete