라벨 이미지 읽기
PNG, JPEG, WebP 또는 GIF 라벨 Data를 scan(image:profile:)에 전달하세요. STOCK-4827이 인코딩된 Code 128 라벨은 해당 문자열을 그대로 반환합니다.
SwiftPM
iOS 13+ · macOS 11+
1D + 2D
MIT
AVFoundation 제어권은 앱에서 유지하면서 정적 XCFramework로 Swift에서 1D 소매·물류 라벨과 2D 매트릭스 코드를 디코딩합니다.
PNG, JPEG, WebP 또는 GIF 라벨 Data를 scan(image:profile:)에 전달하세요. STOCK-4827이 인코딩된 Code 128 라벨은 해당 문자열을 그대로 반환합니다.
반응성 높은 실시간 캡처를 위해 메인 스레드 외부에서 AVFoundation의 원시 RGBA 픽셀을 scanFrame(rgba:width:height:profile:)에 전달합니다.
각 감지 결과의 symbology와 content.text를 Swift String으로 디코딩해 선행 0을 보존한 뒤 자체 재고 API를 조회하세요.
Xcode나 Package.swift에 SwiftPM 저장소를 추가하고 정확한 바코드 문자열과 심볼로지를 반환받으세요.
Xcode 또는 Package.swift에 GitHub의 qrcode-barcode-scanner-swift(Swift Package Index 등재)를 추가한 뒤 타깃에 QRCodeBarcodeScanner 프로덕트를 링크하세요.
SwiftPM이 SHA-256 체크섬으로 고정된 사전 빌드 정적 XCFramework(QrcodeAiScannerFFI)를 다운로드하므로 Rust 툴체인이나 동적 프레임워크 임베드가 필요하지 않습니다.
// 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")
]
)
]
Xcode에서는 File -> Add Package Dependencies에서 https://github.com/qrcode-ai-com/qrcode-barcode-scanner-swift.git 주소를 사용하세요.
XCFramework 슬라이스는 iOS 13+(arm64), iOS 시뮬레이터 13+(arm64, x86_64), macOS 11+(arm64, x86_64)을 포함합니다.
Task.detached 내부에서 scan(image:profile:)을 호출하고 Codable로 ScanReport를 유연하게 파싱한 뒤 재고 워크플로에서 사용하는 바코드 심볼로지만 유지하세요.
알려진 기준 샘플로 테스트하려면 STOCK-4827을 인코딩해 바코드 생성기로 Code 128 바코드를 만든 뒤 내보낸 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
}
손상되었거나 대비가 낮은 라벨 사진에는 "frame"에서 "full"로 전환하고, 실시간 캡처에는 AVFoundation의 원시 RGBA 픽셀을 scanFrame(rgba:width:height:profile:)에 전달하세요.
필요에 따라 pdf417, aztec, code93, codabar, data_bar, data_bar_expanded, telepen 또는 maxi_code를 barcodeFormats에 추가하세요.
STOCK-4827이 인코딩된 Code 128 라벨의 경우 readBarcodeImage는 BarcodeReading(symbology: "code128", text: "STOCK-4827")을 반환합니다. 012345678905 같은 UPC-A 코드는 선행 0이 손실되지 않은 Swift String으로 유지됩니다.
빈 이미지나 QR코드만 있는 사진은 빈 배열을 반환합니다. 잘못된 파일이나 알 수 없는 옵션은 ScanBindingError를 발생시키므로 예외를 catch하고 이전 UI 결과를 초기화하세요.
16가지 바코드 형식 지원. 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, MaxiCode를 디코딩합니다(ISBN은 ean13, GS1-128은 code128, ITF-14는 itf로 매핑).
정적 링크 및 Apple 플랫폼. QrcodeAiScannerFFI는 iOS 13+(arm64), iOS 시뮬레이터 13+(arm64, x86_64), macOS 11+(arm64, x86_64)용으로 정적 링크됩니다. 선행 0을 보존하려면 식별자를 Swift String으로 유지하고 상품 카탈로그는 별도로 조회하세요.
유연한 JSON과 MIT 라이선스. 추가 필드는 선택적으로 디코딩하고 trace.budget_exhausted가 false인지 확인하세요. 현재 릴리스는 MIT 라이선스이며, 자세한 내용은 Swift 패키지 README를 참고하세요.
공식 패키지 문서, ScanReport 명세 및 라이선스 참고 자료입니다.
10가지 SDK 런타임을 모두 비교하거나, 온라인에서 라벨을 스캔하거나, 동일한 엔진으로 iOS에서 QR코드를 읽어보세요.
SwiftPM, 지원 형식, 선행 0 보존, XCFramework, AVFoundation 및 라이선스 안내.
QR Code AI가 오픈소스 MIT 라이선스로 제공하는 Swift Package Manager 라이브러리(qrcode-barcode-scanner-swift의 QRCodeBarcodeScanner)로, 공유 Rust 엔진을 정적 XCFramework로 번들해 iOS와 macOS에서 16가지 1D·2D 바코드 형식과 QR코드를 디코딩합니다.
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, MaxiCode와 QR코드, Micro QR, rMQR을 읽을 수 있습니다. ISBN, GS1-128, ITF-14는 각각 ean13, code128, itf로 반환됩니다.
체크섬이 고정된 정적 XCFramework는 iOS 13+(arm64), iOS 시뮬레이터 13+(arm64, x86_64), macOS 11+(arm64, x86_64)을 지원하며 Rust 툴체인이나 동적 프레임워크 서명이 필요하지 않습니다.
아니요. 스캐너는 인코딩된 각 식별자를 심볼로지(인식된 경우 파싱된 GS1 필드 포함)와 함께 String으로 반환하므로 선행 0이 그대로 유지됩니다. 상품 정보는 자체 카탈로그나 재고 백엔드에서 별도로 조회하세요.
AVFoundation 캡처, 카메라 권한 및 미리보기 UI는 앱에서 직접 제어합니다. 카메라 샘플 버퍼를 RGBA 픽셀로 변환한 뒤 메인 스레드 외부에서 scanFrame(rgba:width:height:profile: "frame")에 전달하세요.
바코드가 감지되지 않으면 detections 배열이 비어 있는 유효한 JSON을 반환합니다(trace.budget_exhausted가 false인지 확인하세요). 손상된 이미지나 알 수 없는 옵션은 ScanBindingError를 발생시킵니다.
아니요. 모든 디코딩은 기기 내 링크된 정적 라이브러리에서 로컬로 실행되므로 네트워크 호출, QR Code AI 계정, 생성 크레딧이 전혀 필요하지 않습니다.
네. 현재 릴리스는 MIT 라이선스로 배포되므로 저작권 및 라이선스 고지(LICENSING.md 참고)를 유지하는 조건으로 상업용 App Store 앱과 엔터프라이즈 소프트웨어에 사용할 수 있습니다. SDK 사용은 QR Code AI의 유료 생성 플랜 및 7일 프리미엄 체험과 별개입니다.