Barcode Selection KMP Skill
Critical: Do Not Trust Internal Knowledge
Scandit's Kotlin Multiplatform (KMP) SDK is new, shipping in 8.6. Your training data almost certainly predates it and contains zero reliable knowledge of its API — do not pattern-match it against the Android or iOS native SDKs you may know, and do not pattern-match it against the barcode-capture-kmp skill either: BarcodeSelection diverges from BarcodeCapture in several specific ways even within the same KMP SDK. The API packages are com.kmp.datacapture.* (NOT com.scandit.datacapture.*).
Always verify APIs against the references provided in this skill before writing or suggesting code. Do not rely on memorized method signatures, parameters, or property names from any other Scandit platform or mode. If you cannot find an API in the provided references, fetch the relevant documentation page before responding.
KMP-specific gotchas worth flagging:
- Import root is
com.kmp.datacapture.barcode.selection.*for the mode/settings/session/listener/overlay,com.kmp.datacapture.barcode.data.*forSymbology/Barcode/CapturePreset. Never writecom.scandit.datacapture.*in KMP code. BarcodeSelectionSettingshas no public constructor — use the factoryBarcodeSelectionSettings.barcodeSelectionSettings(), orBarcodeSelectionSettings.barcodeSelectionSettings(capturePresets: Set<CapturePreset>)to pre-tune for a vertical (CapturePreset.RETAIL,.LOGISTICS,.TRANSPORT,.HEALTHCARE,.MANUFACTURING). WritingBarcodeSelectionSettings()is a compile error.- The mode factory is
BarcodeSelection.forContext(dataCaptureContext, settings)— notforDataCaptureContext(Android-native) and not a raw constructor. settings.selectionTypetakes aBarcodeSelectionTypebuilt from a factory, not a constructor:BarcodeSelectionTapSelection.tapSelection()orBarcodeSelectionAimerSelection.aimerSelection(). Defaults to tap selection.- Switching between Tap-to-Select and Aim-to-Select at runtime does not require recreating
BarcodeSelection: mutatesettings.selectionTypeand callbarcodeSelection.applySettings(settings)(synchronous on KMP — there is no async/Task-returning overload here, unlike some other platforms). - Aimer selection has its own
selectionStrategy(BarcodeSelectionAutoSelectionStrategy()— auto-selects once the algorithm understands intent — orBarcodeSelectionManualSelectionStrategy()— requires aiming + a tap/selectAimedBarcode()call — defaults to manual) and its ownaimerBehavior(BarcodeSelectionAimerBehavior.TOGGLE_SELECTION/.REPEAT_SELECTION, defaults toREPEAT_SELECTION). Tap selection instead hasfreezeBehavior(BarcodeSelectionFreezeBehavior.MANUAL/.MANUAL_AND_AUTOMATIC) andtapBehavior(BarcodeSelectionTapBehavior.TOGGLE_SELECTION/.REPEAT_SELECTION). - The listener interface is
BarcodeSelectionListenerwithonSelectionUpdated(barcodeSelection, session, frameData)andonSessionUpdated(barcodeSelection, session, frameData)as the two methods you must implement (onObservationStarted/onObservationStoppedhave empty default bodies and are optional). Note the parameter isframeData: FrameData?— nullable (it isnullwhen the camera is frozen and the selection changes) — unlikeBarcodeCaptureListener's non-nulldata: FrameData. - Read newly selected/unselected barcodes from
session.newlySelectedBarcodes/session.newlyUnselectedBarcodes(bothList<Barcode>, not a single nullable barcode likeBarcodeCapture'snewlyRecognizedBarcode). Usesession.getCount(barcode)to read how many times a barcode has been selected (relevant withBarcodeSelectionTapBehavior.REPEAT_SELECTION/BarcodeSelectionAimerBehavior.REPEAT_SELECTION, where re-selecting bumps a counter instead of toggling off). BarcodeSelection.createRecommendedCameraSettings()is a companion function onBarcodeSelectionitself (same shape asBarcodeCapture).barcodeSelection.freezeCamera()/barcodeSelection.unfreezeCamera()freeze/resume the live preview so users can carefully tap multiple codes without them moving;barcodeSelection.selectUnselectedBarcodes()selects everything currently tracked;barcodeSelection.selectAimedBarcode()is for manual aimer selection only;barcodeSelection.reset()clears the selection history (counts) without touching enabled/camera state.BarcodeSelectionBasicOverlayhas two factories:withBarcodeSelectionForView(barcodeSelection, view)— binds to a specificDataCaptureView, adds itself automatically — andwithBarcodeSelection(barcodeSelection)(no view binding, used by the Compose composable's declarativeoverlayslist).- The overlay exposes four brush properties, not one:
trackedBrush(barcode recognized but not yet selected/aimed),aimedBrush(currently aimed at, aimer mode only),selectingBrush(transient, during the moment of selection), andselectedBrush(currently selected). Get style defaults viaBarcodeSelectionBasicOverlay.defaultTrackedBrushForStyle(style)/defaultAimedBrushForStyle(style)/defaultSelectedBrushForStyle(style)/defaultSelectingBrushForStyle(style), wherestyleisBarcodeSelectionBasicOverlayStyle.FRAME(default) or.DOT. - The overlay's
viewfinderproperty is read-only (val, notvar) — unlikeBarcodeCaptureOverlay.viewfinder, you cannot assign a differentViewfinderinstance. It is only visible whenselectionTypeisBarcodeSelectionAimerSelection. Style it through the overlay's own hint/brush setters instead of swapping the viewfinder. barcodeSelection.setFeedback(soundEnabled: Boolean, vibrationEnabled: Boolean)is a KMP convenience method for the common case; for finer control assign aBarcodeSelectionFeedbackinstance tobarcodeSelection.feedback(itsselection: Feedbackproperty holds the actual sound/vibration).- Building the camera preview view (
DataCaptureView) is platform-divergent by construction signature, same as every other KMP mode: Android's constructor takes(context: android.content.Context, dataCaptureContext: DataCaptureContext?); iOS's takes only(dataCaptureContext: DataCaptureContext?). SharedcommonMaincode cannot construct aDataCaptureViewdirectly — each platform host constructs it and hands it to a sharedsetupfunction. - To embed the native view: Android uses
view.toAndroidView(): Viewinside a ComposeAndroidViewfactory; iOS usesview.toUIView(): UIViewinside aUIViewRepresentable. These are the only supported bridges — never calltoNative()from application code (it ispubliconly because Kotlin'sinternalcannot span the multi-module KMP SDK). - Teardown order matters and there is no
onDestroy:barcodeSelection.isEnabled = false→barcodeSelection.removeListener(this)→dataCaptureContext.removeMode(barcodeSelection)→camera?.switchToDesiredState(FrameSourceState.OFF). SkippingremoveModeleaves the mode attached to the shared context across screen visits. BarcodeSelectionrequires the MatrixScan add-on entitlement on the license (per the platform-agnostic API doc). If a user's license lacks it,BarcodeSelectionwill not function — this is a licensing question, not a code bug.- The license key placeholder is exactly
-- ENTER YOUR SCANDIT LICENSE KEY HERE --(matches the canonical sample). Use this exact string, not a different placeholder. - On Compose Multiplatform,
BarcodeSelectionhas no dedicated-composecomposable. Use the basecore-composeDataCaptureViewcomposable withoverlays = listOf(overlay)— do not look for aBarcodeSelectionViewcomposable, it does not exist. - Compose overlay instances must be
remember-ed. Thecore-composeDataCaptureViewcomposable diffsoverlaysby content/reference equality every recomposition; a freshBarcodeSelectionBasicOverlaybuilt inline on every recomposition causes constant remove/re-add churn (visible flicker). - Request the
CAMERApermission at runtime on Android before starting the camera (the manifest declaration alone is not sufficient). On iOS,NSCameraUsageDescriptioninInfo.plisttriggers the OS permission prompt automatically on first camera use.
Intent Routing
Based on the user's request, load the appropriate reference file before responding:
- Integrating BarcodeSelection from scratch, choosing tap vs aimer selection, configuring selection strategies, handling selections and per-barcode counts, freezing/unfreezing the camera, customizing overlay brushes, wiring the Compose Multiplatform view, or troubleshooting selection behavior (e.g. "add BarcodeSelection to my KMP app", "let users tap to select barcodes", "switch to aim-to-select", "how many times was this barcode selected", "freeze the camera while selecting", "use BarcodeSelection with Compose Multiplatform") → read
references/integration.mdand follow the instructions there.
API Usage Policy
Only use APIs that are explicitly documented in the Scandit references below. Do not invent or guess method signatures, parameters, or property names — and never carry over a signature from BarcodeCapture, or from the Android-native/iOS-native SDKs, without verifying it also holds for KMP BarcodeSelection. If unsure whether an API exists or how it is called — or if a compile error occurs — fetch the relevant reference page before responding. Do not tell the user to check the docs themselves. After answering, always include the relevant link so the user can explore further.
Never construct or guess documentation URLs. When you need a specific class or property's API page:
- First check whether the page you already fetched contains a direct hyperlink to it — topic pages link directly to relevant API symbols. Always request links alongside content in your fetch prompt.
- If no direct link was found, fetch the API index (see Full API reference in the table below), extract the actual link from it, and follow that.
URL structures can vary and guessing will lead to 404s.
Licence key
Scanning needs a Scandit licence key. For this skill the licence product is native and the licence platforms are ios and android.
Work through these in order — never block the user on MCP:
-
The Scandit MCP server is connected — call
ensure_scanner_setupwith productnativeand platformsiosandandroid,app_identifier(the app's bundle or application id; for web, its production domain, neverlocalhost) andenv_varSCANDIT_LICENSE_KEY. Do not run the command it returns. Then callget_license_keywith the key's id, from that result or fromlist_license_keys; iflist_license_keysshows the key is not a trial, ask the user before fetching it. Show at most a masked preview in chat; never print a full key. -
It is not connected — tell the user once that they can connect the remote Scandit MCP server,
https://ssl.scandit.com/mcp, in their MCP client, then continue from step 1. Do not edit MCP client configuration yourself.Authentication is browser-based, so it is not supported headless or in CI. The server provisions trial keys only; it never creates, revokes, or modifies production licences.
-
The user declines, or has no MCP client — they generate a key themselves at https://ssl.scandit.com (no account yet: https://ssl.scandit.com/dashboard/sign-up?p=test) and paste it in.
Then put the key into the code: write it into the licence-key call in place of the placeholder — the key get_license_key returned, or the one the user pastes or gives you — still showing only a masked preview in chat. Do not search the project, its files or the environment for a key.
References
Direct users to the right resource based on their question:
| Topic | Resource |
|---|---|
| Get Started | Intro · Get Started · references/integration.md |
| Compose Multiplatform | Core Concepts |
| Core concepts (context, camera, views) | Core Concepts |


