一个纯 Swift 编写的 QR 码生成器,没有任何依赖项。
该项目主要直接翻译自 Nayuki 的 Rust QR 码生成器,并进行了一些小的修改,以使代码在 Swift 中更符合语言习惯。
要在你的项目中使用,将以下依赖项添加到你的 Package.swift
文件中
.package(url: "https://github.com/fwcd/swift-qrcode-generator.git", from: "1.0.0")
Swift QR 码生成器可通过 CocoaPods 获得。 要安装它,只需将以下行添加到你的 Podfile
pod 'SwiftQRCodeGenerator'
import QRCodeGenerator
let qr = try! QRCode.encode(text: text, ecl: .medium)
let svg = qr.toSVGString(border: 4)