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
- In Xcode, go to File > Add Package Dependencies.
- Enter the package repository URL.
- Select the
Snapbuglibrary 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
| 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
- 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:
- 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