Scan QRCode or BarCode in iOS Application

How to add ZBar sdk in xcode for QRCode scanner / Barcode scanner?

For creating the QRCode scanner or Bar code scanner application in xcode you have to follow the following steps:

1) Create a new Project of xcode.

2) Add ZBar Sdk in your application.

3) Add following framework :

  • AVFoundation.framework
  • CoreVideo.framework
  • QuartzCore.framework
  • SystemConfiguration.framework
  • CoreMedia.framework
  • AudioToolbox.framework
  • UIKit.framework
  • Foundation.framework
  • CoreGraphics.framework

4) In first view controller of the project add text area for showing the output or result of scan Bar code or QRcode. Also add an image for scanning the code.

5) When you click on the scan button of view controller it will navigates you to the ZBar Sdk library.

// code for the navigation to the view controller to the ZBar Sdk library.

– (IBAction) scanButtonTapped
    ZBarReaderViewController *reader = [ZBarReaderViewController new];
    reader.readerDelegate = self;
    [reader.scanner setSymbology: ZBAR_UPCA config: ZBAR_CFG_ENABLE to: 0];
    reader.readerView.zoom = 1.0;
    [self presentModalViewController: reader
                            animated: YES];

After completing the scanning of the code it will make beep sound and shows the results. Add following code….

– (void) imagePickerController: (UIImagePickerController*) reader
 didFinishPickingMediaWithInfo: (NSDictionary*) info
    id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
    ZBarSymbol *symbol = nil;
    for(symbol in results){
        NSString *upcString =;

//Add beep.mp3 in your resource directory of project.
        NSString *path = [[NSBundle mainBundle] pathForResource:@”beep” ofType:@”mp3″];
        AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
        [theAudio play];

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@”Scanned UPC” message:[NSString stringWithFormat:@”Successful UPC read.”] delegate:self cancelButtonTitle:nil otherButtonTitles:@”Ok”, nil];
        [alert show];
        [reader dismissModalViewControllerAnimated: YES];
Hope it will make you cheers!!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

Up ↑

%d bloggers like this: