1. Swift
  2. Error Reporting

Swift

Error Reporting

You can report problems encountered during on-device OCR extraction using built-in reporting functions. These reports are sent automatically if the device has an internet connection. If not, the SDK will store the report and post it once connectivity is restored.


๐Ÿงพ Reporting an Issue Manually

To report an issue manually from the on-device OCR process, use the following method:

        func reportErrorWith(_ apiKey: String? = nil,
                     andToken token: String? = nil,
                     forModelClass modelClass: VSDKModelExternalClass,
                     withModelSize modelSize: VSDKModelExternalSize = .micro,
                     image: CIImage?,
                     reportText: String,
                     response: Data?,
                     reportModel: VSDKAnalyticsReportModel?,
                     withCompletion completion: ((_ response: Int) -> ())?)

      

๐Ÿ” Parameters:

  • apiKey / token: Required for authentication. Either one must be provided.
  • modelClass: The model type where the error occurred (e.g., .shippingLabel, .itemLabels, .billOfLading).
  • modelSize: The size of the model being used. Supported sizes: .micro, .large.
  • image: (Optional) The image that was used during the scan, passed as a CIImage.
  • reportText: A clear description of the issue you're facing.
  • response: (Optional) The response object (if any) received from the on-device scan.
  • reportModel: (Optional) A custom object to provide structured metadata about the report.
  • completion: A block returning an Int to indicate the result of the error report:
    • 1 โ€“ Error reported successfully
    • 2 โ€“ Error saved for automatic submission later

This method should be called using the shared instance:

        OnDeviceOCRManager.shared.reportErrorWith(...)

      

๐Ÿ“ Retrieving SDK Logs

To assist with debugging or support, you can also retrieve the internal SDK logs using:

        func getVSDKLogs() -> URL?

      

This method returns a URL pointing to a ZIP file that contains SDK usage logs. These logs do not include any user-related or sensitive information and are intended for error tracking purposes only.

Example usage:

        let logsURL = OnDeviceOCRManager.shared.getVSDKLogs()

      

You can upload this ZIP file to your bug report system or share it with the PackageX support team for deeper investigation.