BugScreen
docsios

iOS SDK

v0.1.0

Integrate BugScreen into your iOS app in minutes. Swift, SwiftUI, UIKit, SPM.

Installation

Swift Package Manager

In Xcode, choose File → Add Package Dependencies… and enter the repository URL:

text
https://github.com/bugscreenapp/bugscreen-ios

Or add it to your Package.swift:

Package.swift
swift
dependencies: [
    .package(url: "https://github.com/bugscreenapp/bugscreen-ios", from: "0.1.0")
]

Requires iOS 15.0+ and Swift 5.9+.

Setup

SwiftUI App

Initialize BugScreen in your App struct:

MyApp.swift
swift
import SwiftUI
import BugScreenSDK

@main
struct MyApp: App {
    init() {
        BugScreenSDK.configure(
            apiKey: "fb_your_api_key_here",
            enableScreenshotDetection: true,  // Default: true
            enableLogging: false               // Default: false
        )
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

UIKit App

Initialize BugScreen in your AppDelegate:

AppDelegate.swift
swift
import UIKit
import BugScreenSDK

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        BugScreenSDK.configure(
            apiKey: "fb_your_api_key_here",
            enableScreenshotDetection: true,
            enableLogging: false
        )
        return true
    }
}

Photo Library Access (Recommended)

Add this to your Info.plist so BugScreen can auto-attach the screenshot the user just took, and so users can pick screenshots manually:

xml
<key>NSPhotoLibraryUsageDescription</key>
<string>Attach screenshots to bug reports to help us fix issues faster</string>
Auto-attach: When a screenshot is detected, BugScreen renders a snapshot of the current window and pre-attaches it immediately. If the user grants photo library access, BugScreen also looks up the actual screenshot from Photos and swaps it in. Without permission, the window snapshot remains attached.

Usage

Automatic screenshot detection

When users take a screenshot, BugScreen automatically presents the bug report UI. No additional code required.

Manual triggering (SwiftUI)

Present the bug report screen programmatically:

swift
Button("Report Bug") {
    BugScreenSDK.presentBugReport()
}

// With pre-attached screenshot
Button("Report with Screenshot") {
    BugScreenSDK.presentBugReport(screenshot: myImage)
}

Manual triggering (UIKit)

swift
@IBAction func reportBugTapped(_ sender: UIButton) {
    BugScreenSDK.presentBugReport(from: self)
}

// With screenshot
BugScreenSDK.presentBugReport(
    from: self,
    screenshot: myImage
)

Logging

Add context to bug reports with application logs:

swift
BugScreenSDK.log("Detailed debug info", level: .verbose)
BugScreenSDK.log("Debug message", level: .debug)
BugScreenSDK.log("User tapped checkout button", level: .info)
BugScreenSDK.log("Network request took longer than expected", level: .warn)
BugScreenSDK.log("Payment failed: \(error.localizedDescription)", level: .error)

Logs are automatically included with every bug report. The SDK maintains a 1 MB circular buffer of the most recent logs.

Lifecycle

swift
// Check if SDK is configured
if BugScreenSDK.isConfigured {
    // SDK is ready to use
}

// Optional: Shutdown SDK (usually not needed)
BugScreenSDK.shutdown()

Configuration

OptionDefaultDescription
apiKey: StringRequiredYour API key from the BugScreen console (must start with "fb_")
enableScreenshotDetection: BooltrueAuto-detect screenshots and present bug report UI
enableLogging: BoolfalseEnable debug logs to console (use false in production)

What gets collected?

BugScreen automatically collects this information with each report:

  • Device model (e.g. Apple iPhone16,1)
  • iOS version
  • App version & build number
  • Bundle identifier
  • Screen resolution & scale
  • Screen size (logical points)
  • Memory (total & available)
  • Device locale

Ready to get started?

Create an account to get your API key.

Get started