Speed up MatrixScan Pick integration with Agent Skills
Install the Scandit plugin and use the /matrixscan-pick-ios skill so that your AI coding agent can integrate, debug, and customize MatrixScan Pick on iOS following Scandit's recommended patterns. More info →
Run the following command in your project directory. It detects the supported coding agents you have installed and adds the Scandit plugin to each. Re-run it to update.
npx plugins add scandit/skillsPrefer to set it up yourself? Manual installation steps for each agent →
Get Started With SwiftUI
In this guide you will learn step-by-step how to add MatrixScan Pick to your application using SwiftUI.
The general steps are:
- Create a UIViewController: Implement the MatrixScan Pick logic following the main Get Started guide
- Create a SwiftUI wrapper: Use
UIViewControllerRepresentableto integrate theUIViewController - Use in your SwiftUI app: Add the SwiftUI view to your app's view hierarchy
The core MatrixScan Pick implementation (data capture context, settings, camera setup, etc.) remains the same as described in the main guide.
Create a UIViewController for MatrixScan Pick
To integrate the Scandit Data Capture SDK with SwiftUI, you'll need to create a UIViewController that handles the MatrixScan Pick functionality. This follows the same implementation as described in the main Get Started guide.
Create a MatrixScanPickViewController class that implements all the steps from the UIKit guide:
import ScanditBarcodeCapture
import UIKit
class MatrixScanPickViewController: UIViewController {
private var context: DataCaptureContext!
private var barcodePick: BarcodePick!
private var barcodePickView: BarcodePickView!
override func viewDidLoad() {
super.viewDidLoad()
setupRecognition()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
barcodePickView.start()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
barcodePickView.pause()
if isMovingFromParent {
barcodePickView.stop()
}
}
func setupRecognition() {
// Follow the implementation from the Get Started guide:
// 1. Create data capture context
// 2. Configure the Barcode Pick Mode with product provider
// 3. Setup the Barcode Pick View
// 4. Register the UI delegate and view listener
}
}
extension MatrixScanPickViewController: BarcodePickAsyncMapperProductProviderDelegate {
func mapItems(_ items: [String], completionHandler: @escaping ([BarcodePickProductProviderCallbackItem]) -> Void) {
// Map scanned items to products
// See the main Get Started guide
}
}
extension MatrixScanPickViewController: BarcodePickViewUIDelegate {
func barcodePickViewDidTapFinishButton(_ view: BarcodePickView) {
// Handle finish button tap
}
}
extension MatrixScanPickViewController: BarcodePickActionListener {
func didPickItem(withData data: String, completionHandler: @escaping (Bool) -> Void) {
// Confirm or reject the pick — required for picks to complete.
completionHandler(true)
}
func didUnpickItem(withData data: String, completionHandler: @escaping (Bool) -> Void) {
completionHandler(true)
}
}
extension MatrixScanPickViewController: BarcodePickScanningListener {
func barcodePick(_ barcodePick: BarcodePick, didUpdate scanningSession: BarcodePickScanningSession) {
// Invoked on a background thread every time the picked state of an item changes.
}
func barcodePick(_ barcodePick: BarcodePick, didComplete scanningSession: BarcodePickScanningSession) {
// Invoked when all the registered items needing picking have been picked.
}
}