iOS SDK
The Snapbug iOS SDK is built with Kotlin Multiplatform and distributed as SnapbugSDK.xcframework with a Swift-friendly wrapper. One call installs the full default plugin set: debug feedback overlay, network, analytics, crash reporter, device info, and logs.
Connections work over the Chrome Extension room-code flow (WebRTC, auto-enabled in debug builds) or directly over the local network. Simulators connect to localhost out of the box; physical devices use your machine's LAN IP as serverHost or the room-code flow. Only Apple-silicon simulators are supported (x86_64 simulator slices are excluded).
Installation
- In Xcode, go to File > Add Package Dependencies.
- Enter
https://github.com/snapbug-ai/Snapbug. - Select the
Snapbuglibrary product.
Initialization
Import the module and call Snapbug.start() once 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", // LAN IP for physical devices; nil = localhost
screenNameProvider: { MyRouter.currentScreen },
appVersion: "1.0",
catchFatalErrors: true // default
))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 |
|---|---|---|
| Debug Feedback | Supported | Overlay, screenshots, annotations, bug reports — included in the same framework |
| Network (Ktor) | Supported | Install the Snapbug Ktor plugin in your shared KMP HttpClient |
| Analytics | Supported | Forward analytics events from Swift |
| Crash Reporter | Supported | Fatal error capture on by default (catchFatalErrors) |
| Device Info | Supported | Device/OS metadata in the inspector |
| Logs | Supported | Real-time stdout/stderr capture — see below |
| Deep Links | Not installed by default | |
| Database / SharedPreferences / Tables / Files | Not available on iOS |
Logs
Snapbug.start() installs the logs plugin, which captures the process stdout/stderr (Swift print, NSLog), mirrors it back to the Xcode console, and streams every line into the Logs inspector:
print→ levelI, tagstdoutNSLog→ levelW, tagstderr(the standard NSLog date prefix is stripped)os_log/os.Loggerwrite past stdio and are not captured
Network Plugin (Ktor)
To capture network traffic from a Ktor client, install the plugin in your shared Kotlin Multiplatform code:
val client = HttpClient {
install(SnapbugKtorPlugin)
}Analytics
Forward analytics events from Swift:
import Snapbug
SnapbugAnalyticsHelper.shared.sendEvent(
trackerName: "firebase",
eventName: "screen_view",
properties: ["screen_name": "Home"]
)Limitations
- No no-op artifact on iOS — for clean release builds, guard the
Snapbug.start()call with#if DEBUGor a build flag - KMP naming — the SDK is a Kotlin Multiplatform framework, so some low-level APIs use Kotlin-style naming conventions
- Apple-silicon simulators only —
x86_64simulator slices are excluded (EXCLUDED_ARCHS[sdk=iphonesimulator*] = i386 x86_64)
Sample Project
A complete Swift/SwiftUI sample app is available at sample-ios-swift/ in the repository:
- Build the XCFramework:
./scripts/build-xcframework.sh(runs:debug-feedback:assembleSnapbugSDKReleaseXCFrameworkand copies the result into the Swift package). - Open
sample-ios-swift/SampleApp.xcodeprojin Xcode. - Select an iOS Simulator target, build and run.
Next Steps
- Connect your device
- Troubleshooting for common issues