matrixscan-batch-ios

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MatrixScan Batch iOS Skill

MatrixScan Batch iOS Skill

Critical: Do Not Trust Internal Knowledge

重要提示:请勿依赖内部旧知识

Your training data may contain outdated or incorrect Scandit SDK APIs. The BarcodeBatch API changes between major SDK versions — initializer signatures, overlay constructors, and delegate method names have all evolved (e.g.
BarcodeTracking
BarcodeBatch
).
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. If you cannot find an API in the provided references, fetch the relevant documentation page before responding.
iOS-specific gotchas worth flagging:
  • BarcodeBatch(context: context, settings: settings)
    is a direct convenience initializer — not a factory method like Android's
    BarcodeBatch.forDataCaptureContext(...)
    . Passing a non-nil context auto-attaches the mode to the context.
  • Camera setup is manual: get
    Camera.default
    , call
    context.setFrameSource(camera, completionHandler: nil)
    , then
    camera?.apply(BarcodeBatch.recommendedCameraSettings, completionHandler: nil)
    . Drive the camera from
    viewWillAppear
    /
    viewWillDisappear
    .
  • BarcodeBatchListener.barcodeBatch(_:didUpdate:frameData:)
    is called on a background queue — not the main thread. Dispatch UI work via
    DispatchQueue.main.async {}
    .
  • Do not hold references to
    BarcodeBatchSession.trackedBarcodes
    ,
    addedTrackedBarcodes
    ,
    updatedTrackedBarcodes
    , or
    removedTrackedBarcodes
    outside the callback — copy the data before the callback returns.
  • BarcodeBatchBasicOverlay(barcodeBatch:view:)
    and
    BarcodeBatchAdvancedOverlay(barcodeBatch:view:)
    auto-add the overlay to the
    DataCaptureView
    — no separate
    addOverlay
    call needed.
  • DataCaptureView
    must be
    addSubview
    'd manually
    — unlike
    BarcodeArView
    ,
    DataCaptureView
    does not auto-attach to a parent view.
  • Per-barcode brush customization (
    barcodeBatchBasicOverlay(_:brushFor:)
    ,
    setBrush(_:for:)
    ) requires the MatrixScan AR add-on license. A uniform default brush (no delegate) does not.
  • BarcodeBatchAdvancedOverlay requires the MatrixScan AR add-on license.
  • No built-in feedback
    BarcodeBatch
    never plays a sound or vibrates on its own (unlike
    BarcodeCapture
    /
    SparkScan
    ). Emit feedback manually with
    Feedback.default.emit()
    from inside the listener callback (dispatched to the main thread), gated on
    session.addedTrackedBarcodes
    so it doesn't beep every frame.
  • session.removedTrackedBarcodes
    is an
    [Int]
    of tracking identifiers
    (barcodes that left the frame) — not
    TrackedBarcode
    objects.
    addedTrackedBarcodes
    /
    updatedTrackedBarcodes
    are
    [TrackedBarcode]
    .
  • iOS symbology cases are camelCase:
    .ean13UPCA
    ,
    .code128
    ,
    .qr
    — not
    EAN13_UPCA
    /
    CODE128
    /
    QR
    like Android.
  • iOS delegate methods use Swift naming:
    barcodeBatchBasicOverlay(_:didTap:)
    (not Android's
    onTrackedBarcodeTapped
    ),
    barcodeBatchAdvancedOverlay(_:viewFor:)
    (not
    viewForTrackedBarcode
    ).
  • BarcodeBatchAdvancedOverlayDelegate
    uses
    UIView
    — not Android
    View
    or SwiftUI views.
  • SwiftUI:
    DataCaptureView
    is a
    UIView
    and cannot be dropped into SwiftUI directly. Wrap a UIKit view controller in a
    UIViewControllerRepresentable
    and keep all BarcodeBatch APIs inside that view controller.
  • Cleanup:
    BarcodeBatchListener
    is held as a weak reference, so a missed
    removeListener
    won't leak — but call
    barcodeBatch.removeListener(self)
    in
    deinit
    to make the lifecycle explicit. When using the shared singleton (
    DataCaptureContext.shared
    ), modes stay attached for the app's lifetime — you don't need to call
    removeCurrentMode()
    or
    dispose()
    . Those methods do exist on
    DataCaptureContext
    if you want to tear down explicitly.
  • DataCaptureContext
    exposes two valid initializers:
    DataCaptureContext.initialize(licenseKey:)
    +
    .shared
    (added 7.1.0/7.6.0 — the modern singleton pattern, and what this skill uses) and the older
    DataCaptureContext(licenseKey:)
    convenience init (still non-deprecated, and what the UIKit Get Started page on docs.scandit.com still shows). Prefer the singleton form.
你的训练数据可能包含过时或错误的Scandit SDK API。BarcodeBatch API在SDK主要版本之间会发生变化——初始化器签名、覆盖层构造函数和委托方法名称都已更新(例如
BarcodeTracking
BarcodeBatch
)。
**在编写或建议代码之前,请务必对照本技能中提供的参考文档验证API。**不要依赖记忆中的方法签名、参数或属性名称。如果在提供的参考中找不到某个API,请先获取相关文档页面再回复。
值得注意的iOS特定陷阱:
  • BarcodeBatch(context: context, settings: settings)
    直接便捷初始化器——并非Android中的工厂方法
    BarcodeBatch.forDataCaptureContext(...)
    。传入非nil的context会自动将模式附加到该context。
  • 相机设置是手动操作:获取
    Camera.default
    ,调用
    context.setFrameSource(camera, completionHandler: nil)
    ,然后调用
    camera?.apply(BarcodeBatch.recommendedCameraSettings, completionHandler: nil)
    。在
    viewWillAppear
    /
    viewWillDisappear
    中控制相机。
  • BarcodeBatchListener.barcodeBatch(_:didUpdate:frameData:)
    后台队列中调用——而非主线程。通过
    DispatchQueue.main.async {}
    调度UI操作。
  • 请勿持有
    BarcodeBatchSession.trackedBarcodes
    addedTrackedBarcodes
    updatedTrackedBarcodes
    removedTrackedBarcodes
    的引用——在回调返回前复制数据。
  • BarcodeBatchBasicOverlay(barcodeBatch:view:)
    BarcodeBatchAdvancedOverlay(barcodeBatch:view:)
    自动将覆盖层添加到
    DataCaptureView
    ——无需单独调用
    addOverlay
  • DataCaptureView
    必须手动调用
    addSubview
    添加
    ——与
    BarcodeArView
    不同,
    DataCaptureView
    不会自动附加到父视图。
  • 每个条码的画笔定制
    barcodeBatchBasicOverlay(_:brushFor:)
    setBrush(_:for:)
    )需要MatrixScan AR附加组件许可。使用统一默认画笔(无需委托)则不需要。
  • BarcodeBatchAdvancedOverlay 需要MatrixScan AR附加组件许可。
  • 无内置反馈——
    BarcodeBatch
    本身不会播放声音或震动(与
    BarcodeCapture
    /
    SparkScan
    不同)。在监听器回调中(调度到主线程)手动调用
    Feedback.default.emit()
    触发反馈,并通过
    session.addedTrackedBarcodes
    限制,避免每帧都发出提示音。
  • session.removedTrackedBarcodes
    追踪标识符的数组
    [Int]
    (离开画面的条码)——而非
    TrackedBarcode
    对象。
    addedTrackedBarcodes
    /
    updatedTrackedBarcodes
    [TrackedBarcode]
    类型。
  • iOS码制枚举采用小驼峰式命名
    .ean13UPCA
    .code128
    .qr
    ——而非Android中的
    EAN13_UPCA
    /
    CODE128
    /
    QR
  • iOS委托方法使用Swift命名规范:
    barcodeBatchBasicOverlay(_:didTap:)
    (而非Android的
    onTrackedBarcodeTapped
    )、
    barcodeBatchAdvancedOverlay(_:viewFor:)
    (而非
    viewForTrackedBarcode
    )。
  • BarcodeBatchAdvancedOverlayDelegate
    使用
    UIView
    ——而非Android的
    View
    或SwiftUI视图。
  • SwiftUI:
    DataCaptureView
    UIView
    ,不能直接放入SwiftUI中。将UIKit视图控制器包装在
    UIViewControllerRepresentable
    中,并将所有BarcodeBatch API保留在该视图控制器内。
  • 清理:
    BarcodeBatchListener
    弱引用持有,因此遗漏
    removeListener
    不会导致内存泄漏——但在
    deinit
    中调用
    barcodeBatch.removeListener(self)
    可明确生命周期。使用共享单例(
    DataCaptureContext.shared
    )时,模式会在应用生命周期内保持附加状态——无需调用
    removeCurrentMode()
    dispose()
    。如果需要显式销毁,
    DataCaptureContext
    上确实存在这些方法。
  • DataCaptureContext
    提供两个有效的初始化器:
    DataCaptureContext.initialize(licenseKey:)
    +
    .shared
    (7.1.0/7.6.0版本新增——现代单例模式,本技能使用此方式)和旧版便捷初始化器
    DataCaptureContext(licenseKey:)
    (仍未弃用,docs.scandit.com上的UIKit入门页面仍展示此方式)。优先使用单例形式。

Intent Routing

意图路由

Based on the user's request, load the appropriate reference file before responding:
  • Integrating MatrixScan Batch from scratch, configuring settings, handling tracked barcodes, customizing overlays, adding feedback, or managing lifecycle → read references/integration.md and follow the instructions there. Before writing code, determine whether the project uses UIKit or SwiftUI (check for
    import SwiftUI
    , an
    @main
    App
    struct,
    SceneDelegate
    /
    AppDelegate
    ,
    .storyboard
    /
    .xib
    files, etc.) and use the matching Get Started page from the References table below. If the project already has BarcodeBatch wired up, do not re-create the context, mode, view, or lifecycle — locate the existing ones (grep for
    BarcodeBatch
    , then
    DataCaptureView
    ) and change only what the user asked for.
  • Upgrading the Scandit SDK version (e.g. v6→v7, v7→v8, or "upgrade to the latest") → read references/migration.md. The headline v6→v7 change for MatrixScan Batch is the
    BarcodeTracking
    BarcodeBatch
    rename; the guide also covers the context/camera modernization. Detect the installed version from
    Package.resolved
    /
    Podfile.lock
    before asking the user.
  • Replacing a different barcode scanner with MatrixScan Batch (AVFoundation
    AVCaptureMetadataOutput
    , VisionKit
    DataScannerViewController
    , or another third-party multi-barcode SDK) → read references/third-party-migration.md, then follow references/integration.md for the BarcodeBatch integration.
根据用户请求,在回复前加载相应的参考文件:
  • 从零开始集成MatrixScan Batch、配置设置、处理追踪条码、定制覆盖层、添加反馈或管理生命周期 → 阅读 references/integration.md 并遵循其中的说明。编写代码前,确定项目使用UIKit还是SwiftUI(检查是否有
    import SwiftUI
    @main
    标记的
    App
    结构体、
    SceneDelegate
    /
    AppDelegate
    .storyboard
    /
    .xib
    文件等),并使用下方参考表中对应的入门页面。如果项目已配置好BarcodeBatch,请勿重新创建context、模式、视图或生命周期——找到现有实例(搜索
    BarcodeBatch
    ,然后查找
    DataCaptureView
    ),仅修改用户要求的部分。
  • 升级Scandit SDK版本(例如v6→v7、v7→v8或“升级到最新版本”)→ 阅读 references/migration.md。MatrixScan Batch从v6到v7的核心变化是
    BarcodeTracking
    重命名为
    BarcodeBatch
    ;指南还涵盖了context/相机的现代化更新。在询问用户之前,从
    Package.resolved
    /
    Podfile.lock
    检测已安装的版本。
  • 用MatrixScan Batch替换其他条码扫描器(AVFoundation
    AVCaptureMetadataOutput
    、VisionKit
    DataScannerViewController
    或其他第三方多条码SDK)→ 阅读 references/third-party-migration.md,然后按照 references/integration.md 进行BarcodeBatch集成。

API Usage Policy

API使用规范

Only use APIs that are explicitly documented in the Scandit references below. Do not invent or guess method signatures, parameters, or property names. 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:
  1. 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.
  2. 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 (e.g.
api/ui/
subdirectory) and guessing will lead to 404s.
仅使用以下Scandit参考文档中明确记录的API。请勿自行编造或猜测方法签名、参数或属性名称。如果不确定某个API是否存在或如何调用——或者出现编译错误——请先获取相关参考页面再回复。不要让用户自行查看文档。回复后,请始终包含相关链接,以便用户进一步探索。
**切勿构造或猜测文档URL。**当你需要某个类或属性的API页面时:
  1. 首先检查已获取的页面是否包含直接链接——主题页面会直接链接到相关API符号。在获取内容的请求中始终要求同时获取链接。
  2. 如果未找到直接链接,请获取API索引(见下方表格中的完整API参考),从中提取实际链接并访问该页面。
URL结构可能有所不同(例如
api/ui/
子目录),猜测会导致404错误。

References

参考资料

TopicResource
UIKit integrationGet Started (UIKit) · Sample
SwiftUI integrationGet Started (SwiftUI)
AR overlays (BasicOverlay brushes, AdvancedOverlay views)Adding AR Overlays
Version migration (v6→v7→v8)Migrate 6→7 · Migrate 7→8
Full API referenceBarcodeBatch API
主题资源
UIKit集成入门指南(UIKit) · 示例
SwiftUI集成入门指南(SwiftUI)
AR覆盖层(BasicOverlay画笔、AdvancedOverlay视图)添加AR覆盖层
版本迁移(v6→v7→v8)从v6迁移到v7 · 从v7迁移到v8
完整API参考BarcodeBatch API