Contents

andrealufino/QRDispenser

QR code generator in Swift, with no external dependencies.

Structure

The structure of the library is simple: there's only one class that you use and it's the QRDispenser. It has these methods:

  • generate(from: String, tint: UIColor)
  • generate(url: URL)
  • generate(email: String)
  • generate(phoneNumber: String)
  • generate(wiFiSSID: String, password: String, encryption: WiFiEncryption)
  • generate(latitude: Double, longitude: Double, altitude: Double)
  • generate(location: CLLocation)

Every method returns a UIImage object or throws an error. The error enumeration is QRDispenserError. The code is well documented about every method, if you need more details check directly on Xcode.

There's also a nice thing that I plan to expand in the future that is an extension for URL. The extension has a computed property that returns a QR code containing the url, if the url is a network url (no local ones for now). It works like this:

let url = "https://andrealufino.com"

let qrImage = url.qrRepresentation

I'd like to expand this kind of structure also to other types, like strings, contacts and events.

iOS version

This library needs at least iOS 14.

Installation

The library is available via Swift Package Manager. Just add the url of this repository.

Author

Andrea Mario Lufino, iOS developer since 2010.

Package Metadata

Repository: andrealufino/QRDispenser

Stars: 26

Forks: 3

Open issues: 0

Default branch: main

Primary language: swift

License: MIT

Topics: ios, native, qr, qr-code, qr-code-generator, qr-generator, qrcode, qrcode-generator, swift, uiimage, url

README: README.md