The libqrencode-swift is tiny Swift library for quick and simple generating QR codes. The main goal of creating this wrapper is using lib on the server side. If you backed form iOS or MacOS developing, you probably know that QR code generation is trivial. Unfortunately, we can't using powerful Core Graphics frameworks on server side in Swift. So if you move on to server side code, that way is not applicable.
To integrate library into your code, use SPM
...
dependencies: [
.package(path: "https://github.com/digital-horizon/libqrencode-swift")
]
...
The library works well in Mac OS and Linux – anywhere the Swift toolchain is available.
let str = "https://apple.com"
let colors:[Int] = [120,200,45] // you can optionally set color via components (or pass nil to black by default)
let result = QREncodeSwift.qr(from: str, level: .middle, outputFileName: "qr.png", colorComponents:nil)
if result == true {
// check qr.png file here
}
And viola!
The libqrencode-swfit is released under the MIT License.