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.

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

  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 call Snapbug.start() at app startup:

import Snapbug
 
@main
struct MyApp: App {
    init() {
        Snapbug.start()
    }
 
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

Or with configuration:

import Snapbug
 
Snapbug.start(config: .init(serverHost: "192.168.1.42", appVersion: "1.0"))

For UIKit-based apps:

import Snapbug
 
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        Snapbug.start()
        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
  • Distribution -- available via SPM (package name Snapbug), CocoaPods (pod 'Snapbug'), or manual XCFramework

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