Read saved QR images
Pass encoded PNG, JPEG, WebP or GIF Data from PhotosUI or device storage to scan(image:profile:) off the main thread.
SwiftPM
iOS 13+ · macOS 11+
On-device
MIT
Link a checksum-pinned static XCFramework via Swift Package Manager while your app retains full control over AVFoundation and UI.
Pass encoded PNG, JPEG, WebP or GIF Data from PhotosUI or device storage to scan(image:profile:) off the main thread.
Pass raw RGBA camera pixels to scanFrame(rgba:width:height:profile:) while your app owns AVFoundation and camera 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 (also on the Swift Package Index listing) in Xcode or Package.swift, then link product QRCodeBarcodeScanner to your target.
SwiftPM downloads the prebuilt static XCFramework (QrcodeAiScannerFFI) pinned by SHA-256 checksum, so no Rust toolchain is required and no dynamic framework needs 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, run scan(image:profile:) inside Task.detached so UI rendering stays smooth, and parse 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, pass raw pixels to 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 decide 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 clear stale 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 manages AVFoundation, PhotosUI and camera permissions. Decode ScanReport using optional keys and String enum fields so additive schema updates remain compatible, and confirm trace.budget_exhausted is false.
Licensing and source. Project-authored releases are MIT-licensed (with component notices in LICENSING.md). Refer to the Swift package README for complete 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) that compiles 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 is a static library, there is no dynamic framework to embed or sign in your app bundle.
No. Your SwiftUI or UIKit app owns 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 execute synchronously. Running them in 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 SDK returns valid JSON with an empty detections array (confirm trace.budget_exhausted is false). Unreadable images or unknown options throw ScanBindingError, which your app should catch cleanly.
No. All decoding runs locally on the Apple device inside the statically linked library, with zero network calls, no QR Code AI account, no API key and no creation credits.
Yes. Current releases are published under the MIT licence, allowing commercial App Store and enterprise apps while retaining copyright and licence notices (see LICENSING.md). SDK use is independent of QR Code AI’s paid creation plans and seven-day Premium trial.