A lightweight and efficient iOS framework for QR code scanning using Apple's VisionKit framework. Built with Swift, it provides a customizable scanning interface with real-time detection capabilities.
- 📱 Native iOS QR code scanning using VisionKit
- 🎨 Fully customizable scanner overlay
- 🎯 Region of Interest (ROI) support for precise scanning
- 💫 Real-time QR code detection
- 🔍 High-accuracy scanning
- ⚡️ High frame rate tracking support
- 🛠 Easy integration with existing projects
- iOS 16.0+
- Swift 5.9+
- Xcode 15.0+
Add QRReader to your project through Swift Package Manager by adding the following to your Package.swift dependencies:
.package(url: "https://github.com/mertozseven/QRReader.git", from: "1.0.0")
- Download the QRReader.xcframework
- Drag and drop it into your Xcode project
- Ensure it's embedded and signed in your target's settings
- First, import the framework by adding this line at the top of your file:
import QRReader
- Create a QRReader instance and present the scanner:
let qrReader = QRReader()
if qrReader.isScanningAvailable() {
qrReader.presentScanner(from: viewController) { scannedCode in
print("Scanned QR Code: \(scannedCode)")
}
}
QRReader provides various customization options:
let qrReader = QRReader()
// Customize appearance
qrReader.overlayColor = UIColor.black.withAlphaComponent(0.5)
qrReader.cornerColor = .systemGreen
qrReader.instructionText = "Align QR code within frame"
qrReader.padding = 8
qrReader.windowSize = 250
Property | Type | Description | Default Value |
---|---|---|---|
overlayColor |
UIColor | Scanner overlay background color | black.alpha(0.5) |
cornerColor |
UIColor | Corner markers color | .systemGreen |
instructionText |
String | Guidance text for users | "Align the QR code within the frame to scan" |
padding |
CGFloat | Padding around scanner window | 8 |
windowSize |
CGFloat | Size of scanner window | 250 |
Here's a complete example of implementing QRReader in a view controller:
import UIKit
import QRReader
class ScannerViewController: UIViewController {
private let qrReader = QRReader()
override func viewDidLoad() {
super.viewDidLoad()
setupScanner()
}
private func setupScanner() {
// Customize appearance
qrReader.overlayColor = UIColor.black.withAlphaComponent(0.6)
qrReader.cornerColor = .systemBlue
qrReader.instructionText = "Place QR Code Here"
// Present scanner
if qrReader.isScanningAvailable() {
qrReader.presentScanner(from: self) { [weak self] code in
self?.handleScannedCode(code)
}
}
}
private func handleScannedCode(_ code: String) {
print("Scanned QR Code: \(code)")
}
}
Add the following key to your Info.plist:
<key>NSCameraUsageDescription</key>
<string>Camera access is required for scanning QR codes</string>
- High Performance Scanning: Utilizes VisionKit's DataScannerViewController for efficient QR code detection
- Customizable UI: Fully customizable overlay, corners, and instruction text
- Region of Interest: Focused scanning area for better accuracy
- Real-time Detection: Immediate feedback when QR codes are detected
- Memory Management: Efficient handling of camera resources
This project is available under the GNU General Public License v3.0. See the LICENSE file for more info.
For support, please create an issue in the GitHub repository or contact Mert Adem Özseven.