iOS SDK
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:assembleXCFrameworkIf you plan to use the Debug Feedback plugin:
cd SnapbugAndroid && ./gradlew :debug-feedback:assembleXCFrameworkThe output framework will be located in the module's build/XCFrameworks/ directory.
Installation
Option 1: Manual XCFramework
- Copy the built
snapbug.xcframeworkinto your Xcode project directory. - In Xcode, select your app target, go to General > Frameworks, Libraries, and Embedded Content.
- Click +, then Add Other > Add Files and select the
.xcframework. - Set the embed option to Embed & Sign.
Option 2: Swift Package Manager
If the XCFramework is published or available via a local package:
- In Xcode, go to File > Add Package Dependencies.
- Enter the package repository URL.
- Select the
snapbuglibrary 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
| Feature | Status | Notes |
|---|---|---|
| Network (Ktor) | Supported | Intercept Ktor HTTP client traffic |
| Database | Supported | Browse SQLite databases |
| Analytics | Supported | Monitor analytics events |
| Tables | Supported | Display custom tabular data |
| SharedPreferences | Not available | iOS uses UserDefaults (not yet supported) |
| Deep Links | Not available | Planned for a future release |
| Crash Reporter | Not available | Planned for a future release |
| Debug Feedback | Supported | Requires 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 moduleIn 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:
- Build the XCFrameworks (see Prerequisites).
- Open
sample-ios-swift/SampleApp.xcodeprojin Xcode. - Select an iOS Simulator target.
- Build and run.
Next Steps
- Connect your device to the Desktop app
- Troubleshooting for common issues