Skip to content

Simple framework written in Swift to make all types of code scanning much easier.

Notifications You must be signed in to change notification settings

lukszar/QuickScanner

Repository files navigation

QuickScanner logo

Build passing Swift 4.0 Carthage compatible

QuickScanner

Simple framework written in Swift to make all types of code scanning much easier.

Features

  • Easy integration with Camera features
  • Video permission checking
  • Scanned codes handling with delegates
  • Demo provided

Requirements

  • iOS 10.0+
  • Xcode 9.2+
  • Swift 4.0+

Installation

Carthage

Carthage is a simple, decentralized dependency manager for Cocoa.

You can use Homebrew and install Carthage using the following command:

$ brew update
$ brew install carthage

To use QuickScanner in your Xcode project using Carthage, specify it in your Cartfile:

github "lukszar/QuickScanner"

Run carthage update to build the framework and add QuickScanner.framework into your Xcode project. For any help, check Carthage manual

Usage

In Info.plist file add following code to allow your application to access iPhone's camera:

<key>NSCameraUsageDescription</key>
<string>Allow access to camera</string>

Create variable for your scanner in UIViewController

var qrCodeScanner: QuickScanner!

in viewDidLoad() initialize scanner component with following code:

qrCodeScanner = QuickScanner(codeTypes: [CodeType.qr])
qrCodeScanner.delegate = self

as codeTypes here I used qr type, but you can use list of all types you want to be able to scan with this instance of scanner.

For easy handling scanned codes you have to implement few delegate's methods like following:

func quickScanner(_ scanner: QuickScanner, didCaptureCode code: String, type: CodeType) {
  print(code)
}

func quickScanner(_ scanner: QuickScanner, didReceiveError error: QuickScannerError) {
    print("didReceiveError: \(error)")
}

func quickScannerDidSetup(_ scanner: QuickScanner) {
    scanner.startCapturing()
}

func quickScannerDidEndScanning(_ scanner: QuickScanner) {
}

var videoPreview: UIView {
    return self.view
}

Help

Have you found an error?
Feel free to open new issue and describe your problem.

Do you mind a new feature you would like to add?
Develop your ideas by contributing in this project and adding them here.