Skip to main content

iOS with Swift

Evaluate the Swift source package and fail-closed signed-license verifier before a certified XCFramework is published.

Status
Preview
Integration
Embedded SDK
Distribution
Source preview
Version
0.1.0-RC4

Prerequisites

  • iOS 15 or newer
  • Swift 5.9
  • Apple Security framework
  • Source access to host-ios

1. Use the local Swift package

Use the local Swift package
.package(path: "../PrxVision/host-ios")

No certified remote Swift package or XCFramework is published for RC2.

2. Register a trusted key and apply JWS

Register a trusted key and apply JWS
let verifier = VisionScanJwsVerifier()
verifier.registerPublicKey(kid: keyId, algorithm: .rs256, key: secKey)
let manager = VisionScanEntitlementManager(verifier: verifier)
let result = manager.applySignedLicenseJws(
    signedLicenseJws, expectedTenantId: tenantId, expectedDeviceId: deviceId)
guard result.isAllowed else { throw LicenseError.denied(result.denialReason) }

The host must obtain JWKS through authenticated control-plane networking and convert the selected key to SecKey.

3. Exercise the preview session lifecycle

Exercise the preview session lifecycle
let session = VisionScanSession(
    configuration: .init(executionMode: .liveStreaming, matrixMode: .ar),
    entitlementManager: manager)
try session.start()
// Feed sized AVFoundation luma frames or processLumaFrame(data:...).
let usage = try session.usageSnapshot()
session.close()

Build the native dependency first. Windows Swift source tests validate the real bridge; Apple camera/Security builds and certified delivery remain gates.

Errors and recovery

ConditionResolution
ERR_JWS_UNKNOWN_KEYRefresh JWKS and register the exact kid and algorithm before applying the token.
No decoded observationsExpected in the current source preview; use Android evaluation for a certified customer first-scan journey.

Production checklist

  • Do not ship the source preview as a supported binary
  • Keep JWKS retrieval and SecKey conversion host-owned
  • Test malformed, expired, revoked, and cross-device JWS values
  • Wait for XCFramework publication and certification

Public contract reference

These are the callable methods and HTTP operations used by this guide. Inputs, results, lifecycle rules, and denial behavior are part of the versioned customer contract.

iOS signed-license preview

The source preview verifies JWS claims with Apple Security and does not trust caller-created licenses.

VisionScanEntitlementManager.applySignedLicenseJws(_:expectedTenantId:expectedDeviceId:nowEpochSeconds:)

method

Verify a backend-issued compact JWS and admit its device-bound entitlement claims.

Inputs for VisionScanEntitlementManager.applySignedLicenseJws(_:expectedTenantId:expectedDeviceId:nowEpochSeconds:)
InputTypeRequiredMeaning
jwsStringYesBackend-signed compact JWS.
expectedTenantIdStringYesAuthenticated tenant binding.
expectedDeviceIdStringYesActivated device binding.
Result
VisionScanEntitlementEvaluationResult with allow/deny, state, tier, remediation, and correlation metadata.
Lifecycle
Register the matching trusted public key before applying a JWS; reapply on refresh or revision change.
Trust boundary
The deprecated object-taking applySignedLicense method always denies caller-created claims.
Failure behavior
  • Missing Apple Security crypto, unknown key, bad signature, claim mismatch, expiry, revocation, rollback, or grace expiry deny access.

iOS session preview

Swift consumes the real native MatrixScan bridge; Windows source tests are verified, Apple compilation and certified binaries remain gated.

VisionScanSession.init(configuration:entitlementManager:) -> start() -> processLumaFrame(data:width:height:stride:timestampNs:) -> usageSnapshot() -> pause() -> close()

method

Exercise the Swift session and AVFoundation integration lifecycle.

Inputs for VisionScanSession.init(configuration:entitlementManager:) -> start() -> processLumaFrame(data:width:height:stride:timestampNs:) -> usageSnapshot() -> pause() -> close()
InputTypeRequiredMeaning
configuration.executionModeExecutionModeYesliveStreaming is bridged; batchThroughput/highResolutionRescue and non-default preprocessing profiles are rejected until their configuration bridge is implemented.
luma frameData or sized pointerYesExplicit byte count, fixed luma dimensions and increasing monotonic nanosecond timestamps; verified scan entitlement required.
Result
Real native stable barcode observations, latestMatrixFrame tracks/count/geometry/target/pick state and separate content-free usage snapshots.
Lifecycle
Start once, pause/resume around capture lifecycle, and close deterministically.
Trust boundary
Use for API evaluation only until signed XCFramework packaging and physical-device certification are complete.
Failure behavior
  • Invalid descriptors, unsupported configuration and unverified entitlements fail closed.
  • Windows Swift tests do not certify Apple camera, Security or device execution.

VisionScanMatrixUsageSnapshot.init(nativeJSON: Data) throws; jsonData() throws -> Data

method

Validate and round-trip content-free native visionscan-matrix-usage/v1 snapshots; not an automatic telemetry reporter.

Inputs for VisionScanMatrixUsageSnapshot.init(nativeJSON: Data) throws; jsonData() throws -> Data
InputTypeRequiredMeaning
nativeJSONDataYesBounded UTF-8 native snapshot without the terminating C NUL; no image, payload, geometry, or identity fields.
Result
Immutable typed counters for Batch, AR, Count, Find, or Pick and a closed symbology histogram.
Lifecycle
Read active counters through usageSnapshot; opt-in VisionScanMatrixTelemetry reserves and durably acknowledges separate windows. Enrolled delivery still requires runtime validation.
Trust boundary
No tenant override, keys, tokens, barcode values, or capture bytes. This source codec is not device-to-tenant delivery certification.
Failure behavior
  • Unknown/missing fields, invalid versions/modes, negative or out-of-range counters and inconsistent totals throw.
  • Foundation duplicate-key detection is not provided; Apple compilation and XCTest remain acceptance gates.

VisionScanSession.setTargets([Data]); setPickState(trackId:state:); setScreenScanMode(Bool); latestMatrixFrame: VisionScanMatrixFrame?

method

Expose native target matching, pick transitions and SDK-owned stable tracks to hosts.

Inputs for VisionScanSession.setTargets([Data]); setPickState(trackId:state:); setScreenScanMode(Bool); latestMatrixFrame: VisionScanMatrixFrame?
InputTypeRequiredMeaning
targets[Data]NoAt most 256 raw byte targets, each 1..4096 bytes; use native track IDs for pick.
Result
Copied native targets and typed MatrixScan track/count state in input-luma pixel space, never fabricated UI boxes.
Lifecycle
Start before controls; serialize configuration/capture lifecycle. A new session is required for mode or resolution changes.
Trust boundary
Matrix frame/track payloads are private scan content and must never enter telemetry.
Failure behavior
  • Oversized or empty target values, unknown or unmatched pick tracks and closed sessions throw.

VisionScanMatrixTelemetry.init(session:entitlementManager:controlPlaneOrigin:sdkVersion:storage:maximumQueuedEvents:reportIntervalSeconds:tokenProvider:) throws; flush(completion:); finish(completion:)

method

Deliver opt-in, content-free native usage through a bounded durable outbox using backend-verified enrollment.

Inputs for VisionScanMatrixTelemetry.init(session:entitlementManager:controlPlaneOrigin:sdkVersion:storage:maximumQueuedEvents:reportIntervalSeconds:tokenProvider:) throws; flush(completion:); finish(completion:)
InputTypeRequiredMeaning
storageVisionScanMatrixTelemetryStorageYesApple hosts use VisionScanAppleTelemetryStorage: Keychain key and authenticated AES-GCM, no plaintext fallback.
Result
Typed ready/uploaded/retry/authorization/rejection/identity/full/storage/closed states; stable replay IDs and strict per-event acknowledgments.
Lifecycle
Keep session/storage/reporter alive. Stop capture, then finish to persist the last native window before closing. Storage/full/identity failure preserves the paused session.
Trust boundary
Tenant is backend-derived; no raw license, token, barcode or frame content is persisted or transmitted. Transport retains default TLS trust and denies redirects.
Failure behavior
  • Unverified enrollment, non-HTTPS origins and invalid configuration throw.
  • Corrupt or foreign outboxes fail closed. Apple crypto/TLS and enrolled delivery are unverified external gates.

Review the release support matrix before deployment. Support status and contract failure behavior remain authoritative even when an example is copied.