iOS SDK

iOS

The Snapbug iOS SDK is built with Kotlin Multiplatform and distributed as an XCFramework. It supports network inspection, database browsing, analytics monitoring, and custom tables.

warning

iOS support is currently in beta. Physical device connections are not yet supported -- the SDK works on the iOS Simulator only.

Prerequisites

You need to build the XCFramework from the Snapbug source before integrating it into your Xcode project.

cd SnapbugAndroid && ./gradlew :snapbug:assembleXCFramework

If you plan to use the Debug Feedback plugin:

cd SnapbugAndroid && ./gradlew :debug-feedback:assembleXCFramework

The output framework will be located in the module's build/XCFrameworks/ directory.

Installation

Option 1: Manual XCFramework

  1. Copy the built snapbug.xcframework into your Xcode project directory.
  2. In Xcode, select your app target, go to General > Frameworks, Libraries, and Embedded Content.
  3. Click +, then Add Other > Add Files and select the .xcframework.
  4. Set the embed option to Embed & Sign.

Option 2: Swift Package Manager

If the XCFramework is published or available via a local package:

  1. In Xcode, go to File > Add Package Dependencies.
  2. Enter the package repository URL.
  3. Select the snapbug library product.

Initialization

Import the module and initialize the SDK at app startup:

import snapbug
 
@main
struct MyApp: App {
    init() {
        SnapbugKt.initialize()
    }
 
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

For UIKit-based apps:

import snapbug
 
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        SnapbugKt.initialize()
        return true
    }
}

Supported Features

FeatureStatusNotes
Network (Ktor)SupportedIntercept Ktor HTTP client traffic
DatabaseSupportedBrowse SQLite databases
AnalyticsSupportedMonitor analytics events
TablesSupportedDisplay custom tabular data
SharedPreferencesNot availableiOS uses UserDefaults (not yet supported)
Deep LinksNot availablePlanned for a future release
Crash ReporterNot availablePlanned for a future release
Debug FeedbackSupportedRequires separate XCFramework build

Network Plugin (Ktor)

To capture network traffic from a Ktor client:

import snapbug
 
let client = // your Ktor HttpClient configured in shared KMP code
// The Snapbug Ktor plugin must be installed in the shared module

In your shared Kotlin Multiplatform code:

val client = HttpClient {
    install(SnapbugKtorPlugin)
}

Analytics

Log analytics events from Swift:

import snapbug
 
SnapbugAnalytics.shared.log(
    source: "firebase",
    event: "screen_view",
    params: ["screen_name": "Home"]
)

Limitations

  • Simulator only -- physical iOS device support is not yet available
  • KMP dependency -- the SDK is a Kotlin Multiplatform framework, so some APIs use Kotlin-style naming conventions
  • No CocoaPods -- distribution is via XCFramework or SPM only

Sample Project

A complete Swift/SwiftUI sample app is available at sample-ios-swift/ in the repository. To run it:

  1. Build the XCFrameworks (see Prerequisites).
  2. Open sample-ios-swift/SampleApp.xcodeproj in Xcode.
  3. Select an iOS Simulator target.
  4. Build and run.

Next Steps