Read saved QR images
Pass encoded PNG, JPEG, WebP or GIF Data from PhotosUI or local storage to scan(image:profile:) off the main thread.
SwiftPM
iOS 13+ · macOS 11+
On-device
MIT
Link a checksum-pinned static XCFramework through Swift Package Manager while your app owns AVFoundation and UI.
Pass encoded PNG, JPEG, WebP or GIF Data from PhotosUI or local storage to scan(image:profile:) off the main thread.
Pass raw RGBA camera pixels to scanFrame(rgba:width:height:profile:) while your app controls AVFoundation and permissions.
Parse the returned JSON String with Swift Codable using optional keys and check trace.budget_exhausted and score.
Add the SwiftPM repository in Xcode or Package.swift and decode image Data off the main thread.
Add qrcode-barcode-scanner-swift on GitHub (listed on Swift Package Index) in Xcode or Package.swift, then link product QRCodeBarcodeScanner to your target.
SwiftPM downloads the prebuilt static XCFramework (QrcodeAiScannerFFI) pinned by SHA-256 checksum, requiring no Rust toolchain and no dynamic framework embedding or signing.
// Package.swift
dependencies: [
.package(url: "https://github.com/qrcode-ai-com/qrcode-barcode-scanner-swift.git", from: "0.12.2")
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "QRCodeBarcodeScanner", package: "qrcode-barcode-scanner-swift")
]
)
]
In Xcode, select File -> Add Package Dependencies and paste https://github.com/qrcode-ai-com/qrcode-barcode-scanner-swift.git.
XCFramework slices cover iOS 13+ (arm64), iOS Simulator 13+ (arm64, x86_64) and macOS 11+ (arm64, x86_64).
Import QRCodeBarcodeScanner, invoke scan(image:profile:) inside Task.detached so UI rendering stays fluid, and decode the returned JSON String leniently with optional Codable fields.
import Foundation
import QRCodeBarcodeScanner
struct ScanReportDTO: Decodable {
let detections: [DetectionDTO]
let trace: TraceDTO?
}
struct DetectionDTO: Decodable {
let symbology: String
let content: ContentDTO
}
struct ContentDTO: Decodable {
let text: String
let raw: String?
let charset: String?
}
struct TraceDTO: Decodable { let budget_exhausted: Bool? }
func readQRImage(_ imageData: Data) async throws -> [String] {
try await Task.detached(priority: .userInitiated) {
let json = try scan(image: imageData, profile: "full")
let report = try JSONDecoder().decode(ScanReportDTO.self, from: Data(json.utf8))
guard report.trace?.budget_exhausted != true else { return [] }
return report.detections
.filter { $0.symbology == "qr_code" && $0.content.charset != "unknown" }
.map(\.content.text)
}.value
}
Choose profile "full" (deepest preprocessing + QR score), "fast" (lighter scoring) or "frame" (decode only, score is null).
For live AVFoundation camera buffers, call scanFrame(rgba: pixels, width: width, height: height, profile: "frame") off the main thread.
For a QR image encoding https://qrcode-ai.com/, readQRImage returns ["https://qrcode-ai.com/"]. Show the value in SwiftUI or UIKit and let the user confirm before opening any URL.
An image with no QR code returns empty detections without throwing. Unreadable images or unknown options throw ScanBindingError: catch it and reset previous UI state.
Static XCFramework. QrcodeAiScannerFFI links statically for iOS 13+ (arm64), iOS Simulator 13+ (arm64, x86_64) and macOS 11+ (arm64, x86_64) with SHA-256 verification and no dynamic framework to sign.
App-owned camera and lenient JSON. Your app handles AVFoundation, PhotosUI and camera permissions. Decode ScanReport with optional keys and String enum fields so additive schema updates stay compatible, and confirm that trace.budget_exhausted is false.
Licensing and source. Project-authored releases carry the MIT licence (with component notices in LICENSING.md). See the Swift package README for full build provenance.
Official package documentation, ScanReport specification and licensing references.
SwiftPM, XCFramework, iOS/macOS versions, AVFoundation, threading and licensing.
It is QR Code AI’s open-source MIT-licensed Swift Package Manager library (QRCodeBarcodeScanner from qrcode-barcode-scanner-swift) compiling the shared Rust engine into a static XCFramework for decoding QR codes, Micro QR, rMQR and 16 barcode formats on iOS and macOS.
The prebuilt XCFramework supports iOS 13+ (arm64), iOS Simulator 13+ (arm64 and x86_64) and macOS 11+ (arm64 and x86_64).
No. SwiftPM fetches the prebuilt XCFramework pinned by its SHA-256 checksum in Package.swift, and because QrcodeAiScannerFFI links statically, there is no dynamic framework to embed or sign in your app bundle.
No. Your SwiftUI or UIKit app handles AVFoundation capture, PhotosUI pickers, Info.plist camera permissions and UI overlays. Pass encoded image Data to scan() or raw RGBA pixels to scanFrame().
Both Swift UniFFI functions run synchronously. Calling them inside Task.detached or on a background queue avoids UI hitches while decoding high-resolution photos or live camera frames.
When no code is found, the scanner returns valid JSON with an empty detections array (confirm that trace.budget_exhausted is false). Unreadable images or unknown options throw ScanBindingError, which your app should catch cleanly.
No. Decoding runs locally on the Apple device inside the linked static library, with zero network calls, no QR Code AI account, no API key and no creation credits.
Yes. Current releases carry the MIT licence, permitting commercial App Store and enterprise apps while retaining copyright and licence notices (see LICENSING.md). SDK use is separate from QR Code AI’s paid creation plans and seven-day Premium trial.