iOS QR Code Scanner SDK

Run offline QR code scanning in your iOS and macOS Swift apps. Link the MIT-licensed static XCFramework via Swift Package Manager with no Rust toolchain needed, call scan() or scanFrame() off the main thread and parse the ScanReport JSON locally.

Swift
import Foundation
import QRCodeBarcodeScanner

let json = try scan(image: imageData, profile: "frame")
let report = try JSONSerialization.jsonObject(with: Data(json.utf8)) as? [String: Any]
let rows = report?["detections"] as? [[String: Any]] ?? []
let qr = rows.first { $0["symbology"] as? String == "qr_code" }
let content = qr?["content"] as? [String: Any]

print(content?["text"] as? String ?? "")

Inspect the decoded resulthttps://qrcode-ai.com/

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.

Swift
// 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")
        ]
    )
]

Need to scan a code now? Open the online reader

iOS QR Code Scanner SDK at a glance

  • Checksum-pinned static XCFramework

    SwiftPM

  • arm64 devices & arm64/x86_64 sims

    iOS 13+ · macOS 11+

  • No Rust toolchain or dynamic signing

    On-device

  • Open-source licence

    MIT

Run offline QR scanning on iOS and macOS

Link a checksum-pinned static XCFramework through Swift Package Manager while your app owns AVFoundation and UI.

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.

Scan RGBA camera frames

Pass raw RGBA camera pixels to scanFrame(rgba:width:height:profile:) while your app controls AVFoundation and permissions.

Decode lenient JSON reports

Parse the returned JSON String with Swift Codable using optional keys and check trace.budget_exhausted and score.

Set up QR image reading in Swift on iOS

Add the SwiftPM repository in Xcode or Package.swift and decode image Data off the main thread.

Add QRCodeBarcodeScanner via SwiftPM

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.

Swift
// 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).

Decode a QR image off the main thread

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.

Swift
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.

Inspect the decoded result

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.

XCFramework packaging, Apple platforms and report decoding

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.

Swift QR Code Scanner documentation and licence

Official package documentation, ScanReport specification and licensing references.

iOS QR Code Scanner SDK questions

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.