Latest 1.0.0
Homepage https://github.com/sbhklr/QRCoder
License MIT
Platforms ios 8.0, osx 10.9, requires ARC
Authors

CI Status
Version
License
Platform

Since OSX 10.9 / iOS 7 apple offers a CI filter to generate QR codes.
However, scaling the QR code to the desired size without blurring the image doesn’t work out of the box. The QRCoder library can help you with that. It also contains a handy view controller to scan QR codes (iOS only).

Usage: Generator

Simply use an instance of QRCodeGenerator to create an image of type QRImage. This is a type alias for UIImage under iOS and NSImage under OS X.

QRCoder

let generator = QRCodeGenerator()
//Default correction level is M
generator.correctionLevel = .H
let image:QRImage = generator.createImage("Hello world!",size: CGSizeMake(200,200))

QRCoder

let generator = QRCodeGenerator()
let image:QRImage = generator.createImage("Hello world!",size: CGSizeMake(200,200))

You can set the correction level to one of the values [L,M,Q,H]. The meaning is as follows:

  • Level L – up to 7% damage
  • Level M – up to 15% damage
  • Level Q – up to 25% damage
  • Level H – up to 30% damage

Usage: Scanner (iOS)

QRCoder

class ScannerViewController : QRCodeScannerViewController {

    override func processQRCodeContent(qrCodeContent: String) -> Bool {
        println(qrCodeContent)
        dismissViewControllerAnimated(true, completion: nil)
        return true
    }

    override func didFailWithError(error: NSError) {
        let alert = UIAlertController(title: error.localizedDescription,
            message: error.localizedFailureReason, preferredStyle: .Alert)
        let okAction = UIAlertAction(title: "OK", style: .Default, handler: {
            _ in
            self.dismissViewControllerAnimated(true, completion: nil)
        })
        alert.addAction(okAction)
        presentViewController(alert, animated: true, completion: nil)
    }

}

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Requires OS X 10.9 / iOS 8.

Installation

QRCoder is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "QRCoder"

Version Compatibility

Current Swift compatibility breakdown:

Swift Version Framework Version
4.1 1.x
2.3 0.x

Todo

  • Add QR code scanner for OS X

Contributing

  • Fork it
  • Create new branch to make your changes
  • Commit all your changes to your branch
  • Submit a pull request

Author

Sebastian Hunkeler, @sbhklr

License

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

Latest podspec

{
    "name": "QRCoder",
    "version": "1.0.0",
    "summary": "A QR code generator and scanner for OSX and iOS written in Swift.",
    "description": "Since OSX 10.9 / iOS 7 apple offers a CI filter to generate QR codes.nHowever, scaling the QR code to the desired size without blurringnthe image doesn't work out of the box. The QRCoder library can help you with that.nIt also contains a handy view controller to scan QR codes.",
    "homepage": "https://github.com/sbhklr/QRCoder",
    "screenshots": [
        "https://raw.githubusercontent.com/sbhklr/QRCoder/master/screenshots/ios_code.png",
        "https://raw.githubusercontent.com/sbhklr/QRCoder/master/screenshots/osx_code.png",
        "https://raw.githubusercontent.com/sbhklr/QRCoder/master/screenshots/ios_scanner.png"
    ],
    "license": "MIT",
    "authors": {
        "Sebastian Hunkeler": "[email protected]"
    },
    "source": {
        "git": "https://github.com/sbhklr/QRCoder.git",
        "tag": "1.0.0"
    },
    "social_media_url": "https://twitter.com/sbhklr",
    "requires_arc": true,
    "ios": {
        "source_files": "Pod/Classes/*.swift",
        "frameworks": [
            "Foundation",
            "UIKit",
            "QuartzCore"
        ]
    },
    "osx": {
        "source_files": "Pod/Classes/QRCodeGenerator.swift",
        "frameworks": [
            "Foundation",
            "AppKit",
            "QuartzCore"
        ]
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.9"
    },
    "swift_version": "4.1"
}

Pin It on Pinterest

Share This