How can I scan barcodes on iOS? [closed] How can I scan barcodes on iOS? [closed] ios ios

How can I scan barcodes on iOS? [closed]


We produced the 'Barcodes' application for the iPhone. It can decode QR Codes. The source code is available from the zxing project; specifically, you want to take a look at the iPhone client and the partial C++ port of the core library. The port is a little old, from circa the 0.9 release of the Java code, but should still work reasonably well.

If you need to scan other formats, like 1D formats, you could continue the port of the Java code within this project to C++.

EDIT: Barcodes and the iphone code in the project were retired around the start of 2014.


As with the release of iOS7 you no longer need to use an external framework or library. The iOS ecosystem with AVFoundation now fully supports scanning almost every code from QR over EAN to UPC.

Just have a look at the Tech Note and the AVFoundation programming guide. AVMetadataObjectTypeQRCode is your friend.

Here is a nice tutorial which shows it step by step:iPhone QR code scan library iOS7

Just a little example on how to set it up:

#pragma mark -#pragma mark AVFoundationScanSetup- (void) setupScanner;{    self.device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];    self.input = [AVCaptureDeviceInput deviceInputWithDevice:self.device error:nil];    self.session = [[AVCaptureSession alloc] init];    self.output = [[AVCaptureMetadataOutput alloc] init];    [self.session addOutput:self.output];    [self.session addInput:self.input];    [self.output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];    self.output.metadataObjectTypes = @[AVMetadataObjectTypeQRCode];    self.preview = [AVCaptureVideoPreviewLayer layerWithSession:self.session];    self.preview.videoGravity = AVLayerVideoGravityResizeAspectFill;    self.preview.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);    AVCaptureConnection *con = self.preview.connection;    con.videoOrientation = AVCaptureVideoOrientationLandscapeLeft;    [self.view.layer insertSublayer:self.preview atIndex:0];}


There are two major libraries:

  • ZXing a library written in Java and then ported to Objective C / C++ (QR code only). And an other port to ObjC has been done, by TheLevelUp: ZXingObjC

  • ZBar an open source software for reading bar codes, C based.

According to my experiments, ZBar is far more accurate and fast than ZXing, at least on iPhone.