iOS SDK

iOS

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

Let your AI coding agent do this integration for you — see Install with an AI agent.

Make sure the Podfile sets platform :ios, '15.0' (or higher), then add both lines inside your app target and run pod install. Keep the target's existing use_frameworks! setting and keep using the .xcworkspace.

platform :ios, '15.0'
 
pod 'Snapbug',       '~> 1.0.4', :configurations => ['Debug']
pod 'Snapbug-no-op', '~> 1.0.4', :configurations => ['Release']

Snapbug-no-op is the release twin: same import Snapbug API, every call inert. Your App Store build then ships neither the inspector nor the overlay, and you never guard the call site. See Release builds.

If the project has extra configurations (for example Staging), put one in the live list only if internal testers install builds made from it. Anything that can reach the App Store goes in the no-op list.

Both pods provide a module named Snapbug, and CocoaPods builds both in every configuration. Warnings like Multiple targets match implicit dependency for linker flags '-framework Snapbug' and 'Snapbug-no-op' is missing a dependency on 'Snapbug' are expected and harmless.

Initialization

Call Snapbug.start() once at launch. SwiftUI: in App.init():

import Snapbug
import SwiftUI
 
@main
struct MyApp: App {
    // Optional — only needed for the Home Screen quick action (long-press the app icon
    // to open the Snapbug menu). Everything else works without it.
    @UIApplicationDelegateAdaptor(SnapbugAppDelegate.self) var snapbugDelegate
 
    init() { Snapbug.start() }
 
    var body: some Scene {
        WindowGroup { ContentView() }
    }
}

The SDK waits for the first window scene and attaches the bubble to it. With SDK 0.1.1 the bubble never appeared when started this early; if you are on 0.1.1, upgrade Snapbug.

On CocoaPods you do not guard this call — the Release build links the no-op pod and Snapbug.start() does nothing there. If your app already has its own scene delegate, call Snapbug.handleShortcut(_:) from your own quick-action handler instead of adopting SnapbugAppDelegate.

Or with configuration, in place of the plain call:

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, call it in application(_:didFinishLaunchingWithOptions:):

import Snapbug
 
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
 
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        Snapbug.start()
        return true
    }
}

Info.plist keys

Bug videos are recorded with the reporter's narration on the audio track — the inspector transcribes it into the report. ReplayKit opens the microphone for that, and iOS terminates any app that touches the mic without a usage string, so add:

<key>NSMicrophoneUsageDescription</key>
<string>Microphone is used to narrate bug recordings</string>

The QR pairing scanner needs NSCameraUsageDescription for the same reason:

<key>NSCameraUsageDescription</key>
<string>The camera is used to scan the Snapbug pairing QR code.</string>

If the target has GENERATE_INFOPLIST_FILE = YES and no Info.plist file of its own, add the keys as the build settings INFOPLIST_KEY_NSMicrophoneUsageDescription and INFOPLIST_KEY_NSCameraUsageDescription instead. With XcodeGen or Tuist, add them to the manifest (XcodeGen: info.properties in project.yml), otherwise the next generate erases them.

A missing key is not a permission denial — the process is killed outright, which reads like a crash in the SDK.

Release builds

Android has always had a no-op twin (snapbug-no-op) that turns the SDK into empty calls in release. iOS now has the same thing: the Snapbug-no-op pod. Same Objective-C surface, same Swift wrapper, every call inert, and module_name is still Snapbug — so import Snapbug compiles in both configurations and your code stays identical.

Declared with :configurations as shown above, this is what an App Store build gets:

Debug (live)Release (no-op)
Snapbug.framework in the bundle31 MB6.7 MB
Overlay shown to end usersyesno
Device registers with the inspectoryesno

The 31 MB is the Compose/Skia runtime the overlay is written in — not WebRTC. The published framework contains no WebRTC symbols at all; that transport is a separate snapbug-transport-webrtc module.

Both lines are required. Declaring only pod 'Snapbug', :configurations => ['Debug'] leaves the Release configuration without the Snapbug module, and the build fails to compile.

A green Release build does not prove the swap on its own, because CocoaPods compiles both pods. Check the built Release app instead: Snapbug.framework inside <App>.app/Frameworks/ should be about 7 MB (no-op). About 31 MB means the live SDK leaked into Release. For a simulator build, pass ARCHS=arm64, since the framework has no Intel simulator slice:

xcodebuild -workspace App.xcworkspace -scheme App -configuration Release -sdk iphonesimulator ARCHS=arm64 CODE_SIGNING_ALLOWED=NO build

Supported Features

FeatureStatusNotes
Debug FeedbackSupportedOverlay, screenshots, annotations, bug reports — included in the same framework
Network (Ktor)SupportedInstall the Snapbug Ktor plugin in your shared KMP HttpClient
AnalyticsSupportedForward analytics events from Swift
Crash ReporterSupportedFatal error capture on by default (catchFatalErrors)
Device InfoSupportedDevice/OS metadata in the inspector
LogsSupportedReal-time stdout/stderr capture — see below
Deep LinksNot installed by default
Database / SharedPreferences / Tables / FilesNot 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 → level I, tag stdout
  • NSLog → level W, tag stderr (the standard NSLog date prefix is stripped)
  • os_log / os.Logger write 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 release twin on SPM — Snapbug-no-op is a CocoaPods-only pod, because SPM has no equivalent of :configurations. On the SPM path, guard Snapbug.start() with #if DEBUG yourself
  • KMP naming — the SDK is a Kotlin Multiplatform framework, so some low-level APIs use Kotlin-style naming conventions
  • Apple-silicon simulators only — x86_64 simulator slices are excluded (EXCLUDED_ARCHS[sdk=iphonesimulator*] = i386 x86_64)

Sample Project

A complete Swift/SwiftUI sample app is available at samples/ios-swift/ in the repository:

  1. Build the XCFramework: ./scripts/build-xcframework.sh (runs :debug-feedback:assembleSnapbugSDKReleaseXCFramework and copies the result into the Swift package).
  2. Open samples/ios-swift/SampleApp.xcodeproj in Xcode.
  3. Select an iOS Simulator target, build and run.

Next Steps