iOS Setup Packages
Choose between the aggregate native iOS package, core runtime products, SwiftPM, and CocoaPods, then initialize the Ansight runtime.
The iOS SDK ships as SwiftPM products from the GitHub package and matching CocoaPods pods. Prefer SwiftPM with the aggregate Ansight product for local development because it wires the standard runtime defaults and native tool suites in one place.
Package Manager
SwiftPM
Add the Ansight SDK package to your app project, then choose the products you need.
.package(url: "https://github.com/ansight-ai/ansight-sdk.git", exact: "1.0.2-preview.1")
Aggregate local-development setup:
.product(name: "Ansight", package: "ansight-sdk")
Core-only setup:
.product(name: "AnsightCore", package: "ansight-sdk")
Add individual tool products only when you intentionally need those remote tools:
.product(name: "AnsightToolsVisualTree", package: "ansight-sdk")
.product(name: "AnsightToolsFileSystem", package: "ansight-sdk")
.product(name: "AnsightToolsDatabase", package: "ansight-sdk")
.product(name: "AnsightToolsPreferences", package: "ansight-sdk")
.product(name: "AnsightToolsSecureStorage", package: "ansight-sdk")
.product(name: "AnsightToolsReflection", package: "ansight-sdk")
CocoaPods
The iOS SDK also publishes podspecs that mirror the SwiftPM products.
pod 'Ansight', '1.0.2-preview.1'
For minimal integrations, depend on only the pods you need:
pod 'AnsightCore', '1.0.2-preview.1'
pod 'AnsightPairingQR', '1.0.2-preview.1'
pod 'AnsightToolsVisualTree', '1.0.2-preview.1'
Published CocoaPods packages:
| Pod | Registry |
|---|---|
Ansight | CocoaPods |
AnsightCore | CocoaPods |
AnsightPairingQR | CocoaPods |
AnsightToolsVisualTree | CocoaPods |
AnsightToolsFileSystem | CocoaPods |
AnsightToolsDatabase | CocoaPods |
AnsightToolsPreferences | CocoaPods |
AnsightToolsSecureStorage | CocoaPods |
AnsightToolsReflection | CocoaPods |
AnsightObjC | CocoaPods |
Aggregate Setup
Initialize Ansight once from application startup. In UIKit apps, add the code to
AppDelegate.swift in application(_:didFinishLaunchingWithOptions:). In
SwiftUI lifecycle apps, create an UIApplicationDelegate and attach it with
@UIApplicationDelegateAdaptor. If the app has a SceneDelegate, keep
scene-specific UI or pairing presentation there, but initialize the runtime once
from the app delegate rather than once per scene.
The launch delegate is synchronous, so initialize the runtime directly and start
async pairing from a Task after initialization:
import Ansight
import UIKit
final class AppDelegate: NSObject, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
do {
try AnsightRuntime.shared.initializeAndActivateAnsightSdk()
} catch {
assertionFailure("Ansight failed to initialize: \(error)")
}
Task {
let result = await AnsightRuntime.shared.connect(.auto(clientName: "iOS App"))
if !result.success {
print(result.message)
}
}
return true
}
}
For SwiftUI lifecycle apps, attach that delegate from the app entry point:
import SwiftUI
@main
struct MyApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
The aggregate setup applies the iOS developer defaults, including session JPEG
capture every 2000ms at quality 60, max width 480, and
captureGpuBackedSurfaces: true, then registers native tool suites.
Important: Screen capture will result in an FPS drop while the SDK renders, encodes, and transports frames. Disable session JPEG capture for performance-focused runs unless visual evidence is required.
Customize Aggregate Setup
Use the builder callback to narrow tools, change pairing, or adjust telemetry while keeping the default setup convention.
Put this in the same AppDelegate launch method shown above.
import Ansight
try AnsightRuntime.shared.initializeAndActivateAnsightSdk { options in
options
.withReadOnlyToolAccess()
.withBatteryLevel()
.registerCustomProperty("app", "region", "au")
}
The callback starts from AnsightOptions.ansightDeveloperDefaults.
Core-Only Setup
Put core-only setup in the same AppDelegate launch method. Register scene or
view-specific behavior separately after the runtime is active.
import AnsightCore
let options = try AnsightOptions.createBuilder()
.withSampleFrequencyMilliseconds(500)
.withRetentionPeriodSeconds(600)
.withFramesPerSecond()
.withReadOnlyToolAccess()
.build()
try AnsightRuntime.shared.initializeAndActivate(options: options)
Core-only setup is useful when you need telemetry and host connection without standard native tools.
Developer Build Flags
The SwiftPM build tool and CocoaPods build phase can generate developer pairing artifacts and enforce remote-tool opt-in.
| Setting | Purpose |
|---|---|
ANSIGHT_DEVELOPER_PAIRING_ENABLED=true | Generate and embed a developer pairing artifact from ansight.json. |
ANSIGHT_DEVELOPER_PAIRING_SOURCE_FILE=/absolute/path/to/ansight.json | Override the source pairing file. |
ANSIGHT_ALLOW_REMOTE_TOOLS=true | Permit concrete remote-tool implementations in this build. |
Keep developer pairing and remote tools limited to local development builds. Do not ship them in TestFlight, App Store, CI release, or other distributable builds.