The Problem

Scanning Barcodes on iOS

So you want to scan a barcode. First, you should read about AVCaptureSession. Then you’ll want to make sure to add a AVCaptureDevice to your session. Did you remember to unlock the session configuration before adding the device? What about the AVCaptureDeviceInput? And the AVCaptureVideoPreviewLayer?

Or, you could just use MTBBarcodeScanner, an open source Objective-C library available through CocoaPods or Carthage. MTBBarcodeScanner takes away all the boilerplate code and lets you focus on scanning barcodes.

The Approach

A Simple, Minimal Way to Scan Barcodes

MTBBarcodeScanner doesn’t make any assumptions about how you want to scan barcodes. It doesn’t provide a UI, or an overlay. It lets you provide any UIView to present the video preview.

One More Thing

Bonus Features

In addition to scanning barcodes, MTBBarcodeScanner also has: permission management, tap to focus, camera switching, capture freezing, and still image capture.