Read label images
Pass PNG, JPEG, WebP or GIF label Data to scan(image:profile:). A Code 128 label encoding STOCK-4827 returns that exact string.
SwiftPM
iOS 13+ · macOS 11+
1D + 2D
MIT
Decode 1D retail, warehouse and 2D matrix labels in Swift via a static XCFramework while your app owns AVFoundation.
Pass PNG, JPEG, WebP or GIF label Data to scan(image:profile:). A Code 128 label encoding STOCK-4827 returns that exact string.
Pass raw RGBA pixels from AVFoundation to scanFrame(rgba:width:height:profile:) off the main thread for smooth live capture.
Decode each detection’s symbology and content.text as Swift String so leading zeros stay intact, then query your own inventory API.
Add the SwiftPM repository in Xcode or Package.swift and return exact barcode strings with their symbology.
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, needing no Rust toolchain and no dynamic framework embedding.
// 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 with 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).
Call scan(image:profile:) inside Task.detached, decode ScanReport leniently with Codable and filter for the barcode symbologies your inventory workflow handles.
To test against a known reference, create a Code 128 barcode with Barcode Generator encoding STOCK-4827 and scan the exported PNG.
import Foundation
import QRCodeBarcodeScanner
struct BarcodeReading { let symbology: String; let text: String }
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 charset: String? }
struct TraceDTO: Decodable { let budget_exhausted: Bool? }
private let barcodeFormats: Set<String> = [
"code128", "code39", "ean13", "ean8", "upc_a", "upc_e", "itf", "data_matrix"
]
func readBarcodeImage(_ imageData: Data) async throws -> [BarcodeReading] {
try await Task.detached(priority: .userInitiated) {
let json = try scan(image: imageData, profile: "frame")
let report = try JSONDecoder().decode(ScanReportDTO.self, from: Data(json.utf8))
guard report.trace?.budget_exhausted != true else { return [] }
return report.detections
.filter { barcodeFormats.contains($0.symbology) && $0.content.charset != "unknown" }
.map { BarcodeReading(symbology: $0.symbology, text: $0.content.text) }
}.value
}
Switch from "frame" to "full" for damaged or low-contrast label photos; pass raw AVFoundation RGBA pixels to scanFrame(rgba:width:height:profile:) for live capture.
Add pdf417, aztec, code93, codabar, data_bar, data_bar_expanded, telepen or maxi_code to barcodeFormats as needed.
For a Code 128 label encoding STOCK-4827, readBarcodeImage returns BarcodeReading(symbology: "code128", text: "STOCK-4827"). A UPC-A value such as 012345678905 keeps its leading zero intact as a Swift String.
A blank image or QR-only photo returns an empty array. Invalid files or unknown options throw ScanBindingError: catch it and clear stale UI results.
Sixteen barcode formats. Decodes EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar, GS1 DataBar Expanded, Data Matrix, PDF417, Aztec and MaxiCode (ISBN maps to ean13, GS1-128 to code128, ITF-14 to itf).
Static linking and Apple platforms. QrcodeAiScannerFFI links statically for iOS 13+ (arm64), iOS Simulator 13+ (arm64, x86_64) and macOS 11+ (arm64, x86_64). Keep identifiers as Swift String so leading zeros survive and query product catalogues separately.
Lenient JSON and MIT licence. Parse additive keys optionally and verify that trace.budget_exhausted is false. Current releases carry the MIT licence; see the Swift package README.
Official package documentation, ScanReport specification and licensing references.
SwiftPM, formats, leading zeros, XCFramework, AVFoundation and licensing.
It is QR Code AI’s open-source MIT-licensed Swift Package Manager library (QRCodeBarcodeScanner from qrcode-barcode-scanner-swift) bundling the shared Rust engine into a static XCFramework for decoding 16 1D and 2D barcode formats plus QR codes on iOS and macOS.
It decodes EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar, GS1 DataBar Expanded, Data Matrix, PDF417, Aztec and MaxiCode, plus QR Code, Micro QR and rMQR. ISBN, GS1-128 and ITF-14 return ean13, code128 and itf.
The checksum-pinned static XCFramework supports iOS 13+ (arm64), iOS Simulator 13+ (arm64, x86_64) and macOS 11+ (arm64, x86_64), requiring no Rust toolchain or dynamic framework signing.
No. Each encoded identifier is returned as a String alongside its symbology (and parsed GS1 fields when recognised), keeping leading zeros intact. Query your own product catalogue or inventory backend separately.
Your app owns AVFoundation capture, camera permissions and preview UI. Convert camera sample buffers to RGBA pixels and pass them to scanFrame(rgba:width:height:profile: "frame") off the main thread.
When no barcode is found, the scanner returns valid JSON with an empty detections array (confirm that trace.budget_exhausted is false). Corrupt images or unknown options throw ScanBindingError.
No. Decoding runs locally on the 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 for 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.