Configuration

Configure native iOS sampling, memory channels, screenshots, touch input, pairing, lifecycle capture, custom properties, and tool guard policy.

Configure iOS with AnsightOptions or AnsightOptions.createBuilder().

import Ansight

try AnsightRuntime.shared.initializeAndActivateAnsightSdk { options in
    options
        .withReadOnlyToolAccess()
        .withBatteryLevel()
}

The aggregate setup applies FPS sampling, 400ms sampling, 120s retention, JPEG capture at 2000ms / quality 60 / max width 480 with GPU-backed surface capture enabled, touch capture, UIKit lifecycle capture, host auto-probe, full tool access, and standard native tool registration.

Important: Screen capture will result in an FPS drop while the SDK renders, encodes, and transports frames. Disable session JPEG capture for trend-focused runs unless visual evidence is required.

Core Options

import AnsightCore

let options = try AnsightOptions.createBuilder()
    .withSampleFrequencyMilliseconds(500)
    .withRetentionPeriodSeconds(600)
    .withFramesPerSecond()
    .withBatteryLevel()
    .withSessionJpegCapture(
        intervalMilliseconds: 2000,
        quality: 60,
        maxWidth: 480,
        captureGpuBackedSurfaces: true
    )
    .withReadOnlyToolAccess()
    .build()

try AnsightRuntime.shared.initializeAndActivate(options: options)

Defaults

AnsightOptions() starts with conservative core defaults:

  • sample frequency 500ms
  • retention 600s
  • FPS enabled
  • battery disabled
  • open-file-handle tracking disabled
  • platform default memory channels
  • no session JPEG capture unless configured
  • touch capture enabled by default in native options
  • crash capture enabled with host handoff and offline attachment
  • tool guard disabled
  • host auto-probe enabled
  • cellular host connections disabled
  • unattended provisioning disabled

AnsightOptions.ansightDeveloperDefaults uses the aggregate local-development defaults.

Option Surface

OptionPurpose
sampleFrequencyMillisecondsBuilt-in telemetry sampling interval. Clamped to 200-2000ms.
retentionPeriodSecondsLocal metric/event retention window. Clamped to 60-3600s.
additionalChannelsCustom metric channels. Reserved ids are rejected.
defaultMemoryChannelsBuilt-in memory channels such as managed heap and physical footprint.
enableFramesPerSecondEnables CADisplayLink FPS sampling.
enableBatteryLevelEnables UIDevice battery sampling.
enableOpenFileHandleTrackingEnables process open-file-handle sampling on reserved channel 7.
lifecycleCaptureControls automatic UIKit lifecycle and screen-view capture.
sessionJpegCaptureConfigures live JPEG streaming, visual-tree capture mode, keyboard-presence metadata, and GPU-backed surface capture. nil disables it.
touchCaptureConfigures app-local touch capture. nil disables it.
crashCaptureControls durable native crash capture and next-launch delivery.
toolGuardControls remote-tool discovery and execution.
customPropertiesGrouped string properties sent with session.open.
hostAutoProbeControls automatic reconnect attempts.
hostConnectionConfigures enrollment reconnect, explicit payloads, and host retry behavior.

Tool Guard

PresetMaximum policy
.disabledNone
.readOnly.read
.readWrite.write
.fullAccess.critical

Critical tools such as file delete, preference removal, secure-storage access, arbitrary reflection, and sensitive UI operations require .fullAccess.

Host Auto-Probe

let options = try AnsightOptions.createBuilder()
    .withHostAutoProbe(
        AnsightHostAutoProbeOptions(
            enabled: true,
            initialDelayMilliseconds: 1_000,
            probeIntervalMilliseconds: 5_000,
            reconnectDelayMilliseconds: 10_000,
            clientName: "iOS App"
        )
    )
    .build()
PropertyDefault
enabledtrue
initialDelayMilliseconds1000
probeIntervalMilliseconds5000
reconnectDelayMilliseconds10000
clientNamenil

Disable it when you want explicit pairing only:

let options = try AnsightOptions.createBuilder()
    .withoutHostAutoProbe()
    .build()

Host Connection Policy

Cellular host connections are rejected by default for QR enrollment, saved profiles, and explicit connection requests. Opt in only when a development workflow intentionally uses mobile data or a personal hotspot:

let options = try AnsightOptions.createBuilder()
    .withCellularHostConnections()
    .build()

This can consume mobile data and does not change the clear-text local-development transport.

Unattended provisioning is separately disabled by default. A trusted native test runner can opt in with .withUnattendedProvisioning() and place a fresh one-use invite in the ANSIGHT_ENROLLMENT_PAYLOAD process environment variable before app launch. The SDK consumes it before remembered profiles and retains the successful installation registration in app-private storage. Use this only in development/test variants and never log the bearer payload.

Crash Capture

Crash capture is enabled by default. Configure it explicitly when retention or delivery policy differs:

let options = try AnsightOptions.createBuilder()
    .withCrashCapture(
        AnsightCrashCaptureOptions(
            hostHandoffEnabled: true,
            offlineCaptureAttachmentEnabled: true,
            maximumPendingReports: 8,
            retentionDays: 7,
            maximumBreadcrumbs: 64,
            maximumTraceBytes: 1_048_576
        )
    )
    .build()

Use .withoutCrashCapture() when the app must not write a crash outbox. See Crash Capture for recovery and privacy details.