Tools

Add native iOS remote tool suites, artifact providers, or custom app tools, gate them with the iOS build opt-in and ToolGuard, and keep them limited to local development workflows.

Remote tools let the local host player and CLI clients inspect or operate on a paired iOS app. Keep them scoped to local development and QA builds.

Important Security Rule

Do not ship native tool suites in TestFlight, App Store, CI release, or other distributable builds unless the capability is explicitly approved.

Do this:

  • add the aggregate Ansight product or individual tool products only to local development builds
  • set ANSIGHT_ALLOW_REMOTE_TOOLS=true only for those local builds
  • use the narrowest runtime guard that works for the workflow

Do not do this:

  • ship tool products in distribution builds
  • leave ANSIGHT_ALLOW_REMOTE_TOOLS=true in shared release configuration
  • expose write or critical tools when read-only inspection is enough

Build-Time Opt-In

export ANSIGHT_ALLOW_REMOTE_TOOLS=true

Without this local-development opt-in, the SwiftPM build tool and CocoaPods build phase fail when they detect concrete AnsightTool implementations.

Runtime Registration

The aggregate Ansight product registers the standard native tool suites for you:

import Ansight

let options = try AnsightOptions.createBuilder(.ansightDeveloperDefaults)
    .withReadOnlyToolAccess()
    .build()

try AnsightRuntime.shared.initializeAndActivateAnsightSdk(options: options)

Core-only apps can register suites directly:

import AnsightCore
import AnsightToolsDatabase
import AnsightToolsFileDescriptorDiagnostics
import AnsightToolsFileSystem
import AnsightToolsPreferences
import AnsightToolsReflection
import AnsightToolsSecureStorage
import AnsightToolsVisualTree

try AnsightRuntime.shared.registerVisualTreeTools()
try AnsightRuntime.shared.registerDatabaseTools()
try AnsightRuntime.shared.registerFileDescriptorDiagnosticsTools()
try AnsightRuntime.shared.registerFileSystemTools()
try AnsightRuntime.shared.registerPreferencesTools()
try AnsightRuntime.shared.registerReflectionTools()
try AnsightRuntime.shared.registerSecureStorageTools()

Registered tools stay hidden and unusable until toolGuard allows their policy.

Runtime Availability

tool.query evaluates each visible tool against current app state. Catalog entries include runtime.available, reasonCode, reason, requiredState, remediation, retryable, and evaluatedAtUtc, plus a top-level executable flag. Availability is evaluated again immediately before tool.call; an unavailable call returns a structured error instead of running the tool. Tools without prerequisites return .availableNow.

Suite Registration API

SuiteProductCommon registration API
VisualTreeAnsightToolsVisualTreeregisterVisualTreeTools()
DatabaseAnsightToolsDatabaseregisterDatabaseTools(options:), AnsightDatabaseToolsOptions.createBuilder(), addRoot(alias:path:), includePlatformRoots(...)
FileSystemAnsightToolsFileSystemregisterFileSystemTools(options:), AnsightFileSystemToolsOptions.createBuilder(), addRoot(alias:path:)
File Descriptor DiagnosticsAnsightToolsFileDescriptorDiagnosticsregisterFileDescriptorDiagnosticsTools(options:), AnsightFileDescriptorDiagnosticsOptions(...)
PreferencesAnsightToolsPreferencesregisterPreferencesTools(options:), AnsightPreferencesToolOptions(defaultStore:allowedStores:allowedKeys:allowedKeyPrefixes:)
SecureStorageAnsightToolsSecureStorageregisterSecureStorageTools(options:), AnsightSecureStorageToolsOptions.createBuilder(), withStorageIdentifier(...), withAppleService(...), allowKey(...), allowKeyPrefix(...)
ReflectionAnsightToolsReflectionAnsightReflectionRootRegistry.register(...), registerGetter(...), deregister(...), clear(), registerReflectionTools(options:), AnsightReflectionToolsOptions.createBuilder(), allowRoot(...), allowTypePrefix(...)
Custom Toolsapp coderegisterTool(_:), registerTool(_:replaceExisting:), isToolRegistered(...)
ArtifactsAnsightCore / AnsightregisterArtifactProvider(...), registerArtifactProviders(...), unregisterArtifactProvider(...), clearArtifactProviders()

Guard Levels

GuardWhat it allows
withToolsDisabled() / .disabledNo discovery, no execution.
withReadOnlyToolAccess() / .readOnlyMaximum policy .read.
withReadWriteToolAccess() / .readWriteMaximum policy .write.
withAllToolAccess() / .fullAccessMaximum policy .critical.

Tool Suites

Artifacts are a core provider model rather than a separate native tool package. Registering an artifact provider adds the .read policy artifacts.query and artifacts.request tools. See Artifacts.

SuiteProductTypical use
VisualTreeAnsightToolsVisualTreeInspect the foreground UIKit hierarchy, capture screenshots, and manage diagnostic overlays.
DatabaseAnsightToolsDatabaseDiscover SQLite databases, inspect schema, and run read-only queries.
FileSystemAnsightToolsFileSystemList directories, read files, download files, push, copy, move, and delete files inside approved roots.
File Descriptor DiagnosticsAnsightToolsFileDescriptorDiagnosticsCount and inspect open process descriptors, limits, and utilization.
PreferencesAnsightToolsPreferencesRead and mutate UserDefaults values under store/key allow-lists.
SecureStorageAnsightToolsSecureStorageRead and mutate Keychain values under explicit key allow-lists.
ReflectionAnsightToolsReflectionInspect explicitly registered live object roots and optionally call root-owned mutation/invocation adapters.
Custom Toolsapp codeExpose narrow app-specific development operations.

For most teams:

  1. Start with VisualTree and Database.
  2. Use .readOnly by default.
  3. Use File Descriptor Diagnostics for resource-leak investigations, with targets disabled unless paths are needed.
  4. Add FileSystem, Preferences, or SecureStorage only for a specific debugging workflow.
  5. Add Reflection only after registering narrow roots and type/root filters.
  6. Add Artifacts when app-specific output should become a streamed file or durable session artifact.
  7. Add Custom Tools only for narrow operations that packaged suites cannot cover.
  8. Keep write and delete operations off unless the workflow genuinely depends on them.