Barcode Capture 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. The KMP API packages are com.kmp.datacapture.* (NOT com.scandit.datacapture.*), and shapes diverge from both native SDKs in specific ways (see below).
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. 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.*— e.g.com.kmp.datacapture.barcode.capture.BarcodeCapture,com.kmp.datacapture.core.capture.DataCaptureContext. Never writecom.scandit.datacapture.*in KMP code. BarcodeCaptureSettingshas no public constructor — use the factoryBarcodeCaptureSettings.barcodeCaptureSettings()(or the capture-presets overload). WritingBarcodeCaptureSettings()is a compile error.codeDuplicateFilteris a plainLongon KMP — notTimeInterval(iOS/Android-native) and not a.NET TimeSpan. Do not wrap it in a duration type.- The listener interface is
BarcodeCaptureListenerwithonBarcodeScanned(barcodeCapture, session, data)andonSessionUpdated(barcodeCapture, session, data)as the two methods you must implement;onObservationStarted/onObservationStoppedhave empty default bodies and are optional overrides. TheFrameDataparameter is nameddata. BarcodeCapture.forContext(dataCaptureContext, settings)is the factory — notforDataCaptureContext(Android-native) and not a raw constructor.Camera.getDefaultCamera(BarcodeCapture.createRecommendedCameraSettings())passes the recommended camera settings directly — there is no separateapplySettingscall needed for initial setup.- Building the camera preview view (
DataCaptureView) is platform-divergent by construction signature: 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 the
view.toAndroidView(): Viewextension inside a ComposeAndroidViewfactory (or a plainViewGroup); iOS usesview.toUIView(): UIViewinside aUIViewRepresentable. These are the only supported bridges — never calltoNative()from application code (it's public only because Kotlin'sinternalcannot span the multi-module KMP SDK). BarcodeCaptureOverlay.withBarcodeCaptureForView(barcodeCapture, view)attaches the overlay to a specificDataCaptureViewand adds it in one step conceptually, but you must still callview.addOverlay(overlay)yourself — the factory only constructs the overlay. There's alsoBarcodeCaptureOverlay.withBarcodeCapture(barcodeCapture)(no view binding), used by the Compose composable which takes overlays as a declarative list instead.- Teardown order matters and there is no
onDestroy:barcodeCapture.isEnabled = false→barcodeCapture.removeListener(this)→dataCaptureContext.removeMode(barcodeCapture)→camera?.switchToDesiredState(FrameSourceState.OFF). SkippingremoveModeleaves the mode attached to the shared context across screen visits, degrading performance. LaserlineViewfinderis NOT available on KMP — onlyRectangularViewfinderandAimerViewfindership in the KMP viewfinder package. Do not suggest a laser-line viewfinder for a KMP app.- 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,
BarcodeCapturehas no dedicated-composecomposable (unlike SparkScan, BarcodeCount, BarcodeFind, BarcodeAr, BarcodePick). Use the basecore-composeDataCaptureViewcomposable withoverlays = listOf(overlay)— do not look for aBarcodeCaptureViewcomposable, it does not exist. - Compose overlay instances must be
remember-ed. Thecore-composeDataCaptureViewcomposable diffsoverlaysby content/reference equality every recomposition; a freshBarcodeCaptureOverlaybuilt 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) — see the canonical sample'sHomeScreen.ktpermission-launcher pattern. 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 BarcodeCapture from scratch, configuring settings, customizing feedback, adding a viewfinder, handling scans, wiring the Compose Multiplatform view, or doing async work after a scan (e.g. "add BarcodeCapture to my KMP app", "set up barcode scanning in my shared module", "how do I use BarcodeCapture with Compose Multiplatform", "filter duplicate scans", "suppress the beep", "add a viewfinder", "disable scanning while I look up the barcode") → 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 the Android-native or iOS-native SDKs without verifying it also holds for KMP. 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 | Get Started |
| Configure symbologies | Configure Barcode Symbologies |
| Compose Multiplatform | Core Concepts |
| Core concepts (context, camera, views) | Core Concepts |


