GitHunt
D-

d-date/SwiftBarcodeReader

Capturing Barcode / QR written in Swift

SwiftBarcodeReader

This is a helper library for capturing barcode or QR written in Swift.

Usage

On calling presentBarcodeReader, capturing View Controller will be modaled.

You can specifiy AVMetadataObjectTypes as enum, requirement of change camera position button and handling result/error using closure.

import SwiftBarcodeReader

func appear(){
        presentBarcodeReader(scanTypes: [.EAN13Code], //you can specify code type to scan type as enum value
                             needChangePositionButton: true, // If you need change position button, pass `true`
                             success: { (type, value) in
            print("type:\(type) value:\(value)")
            self.resultLabel.text = "\(value)"

        }) {(canceled, error) in
            
            //cancel handle when tapped back button
            if canceled {
                print("canceled")
            }
            
            //error handle when occured some error
            if error != nil {
                print("error:\(error)")
            }
        }
    }

Requirements

  • Xcode 8 and Swift 3.0
  • iOS 8.0 and later

Installation

Cocoapod

pod "SwiftBarcodeReader"

Carthage

Prepare Cartfile, then add below.

github "d-date/SwiftBarcodeReader"

Run below on Terminal.

carthage update --platform-iOS

Author

Daiki Matsudate(@d_date)

Contribute

If you want to add new feature or fix bug, make an issue first and try to contact me.

License

SwiftBarcodeReader is available under the MIT license. See the LICENSE file for more info.

TODO

  • Custermizable Capturing UI
  • Show Capturing Rect

Languages

Swift89.2%Objective-C7.0%Ruby3.8%
MIT License
Created October 2, 2016
Updated October 30, 2023