Skip to content

iOS SDK (Native Swift)

The Mobore iOS SDK is a native Swift library for Real User Monitoring on Apple platforms. It provides zero-configuration auto-instrumentation for crashes, network requests, screen transitions, taps, hangs, and more — all exported as OpenTelemetry signals over OTLP/HTTP.

For the complete and most up-to-date reference, see the full documentation on GitHub.

PlatformMinimum Version
iOS16.0
macOS13.0
tvOS16.0
watchOS10.0

In Xcode:

  1. Navigate to File > Add Package Dependencies…
  2. Enter https://github.com/mobore/mobore-ios-sdk.git
  3. Select Up to Next Major Version starting from 0.9.4
  4. Add MoboreIosSdk to your app target

Or add it directly in Package.swift:

dependencies: [
.package(url: "https://github.com/mobore/mobore-ios-sdk.git", .upToNextMajor(from: "0.9.4"))
]
pod 'MoboreIosSdk', '~> 0.9.0'
Terminal window
pod install

Start the SDK as early as possible in your app lifecycle. A single call enables all auto-instrumentation with sensible defaults.

UIKit

import MoboreIosSdk
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
MoboreIosSdkAgent.start()
return true
}
}

SwiftUI

import SwiftUI
import MoboreIosSdk
@main
struct MyApp: App {
init() {
MoboreIosSdkAgent.start()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}

Pass a custom configuration to control the collector endpoint, environment, and sampling:

let config = MoboreAgentConfigBuilder()
.withClientToken("YOUR_CLIENT_TOKEN")
.withEnvironment("production")
.withSessionSampleRate(1.0)
.build()
MoboreIosSdkAgent.start(with: config)
OptionDefaultDescription
clientTokennilAuthorization header for OTLP exports
environment"development"Deployment environment name
exportUrlhttps://traces.mobore.comCollector endpoint
sessionSampleRate1.0Session-level sampling (0.0 to 1.0)

All of the following are captured out of the box with default settings:

  • Crashes — native signal and Mach exception handling via PLCrashReporter
  • App hangs — main thread blocked > 2 seconds
  • Network requests — all URLSession traffic with status codes and timings
  • Screen transitions — UIViewController lifecycle and SwiftUI hosting controllers
  • Tap events — target, action, element metadata, and coordinates
  • App lifecycle — active, inactive, background, foreground, terminate
  • Push notifications — foreground delivery and user taps
  • WebView navigation — WKWebView request, start, finish, and error events
  • System metrics — CPU and memory usage gauges
  • MetricKit — launch times, hang times, and exit statistics
  • Low power mode — state change detection
  • Session usage — active screen time tracking with inactivity detection

Each module can be individually toggled. See the instrumentation configuration reference for all options.

The SDK exposes static methods on MoboreIosSdkAgent for custom telemetry:

// Track a view manually (useful for SwiftUI)
MoboreIosSdkAgent.startView(name: "Checkout")
MoboreIosSdkAgent.endCurrentView()
// Record a custom action
MoboreIosSdkAgent.addAction(name: "add_to_cart", attributes: ["product_id": "SKU-123"])
// Report an error
MoboreIosSdkAgent.addError(message: "Payment failed", source: "PaymentService")
// Emit a log
MoboreIosSdkAgent.addLog(message: "Order placed", level: "info", attributes: ["order_id": "456"])
// Set user context
MoboreIosSdkAgent.setUser(["id": "user-789", "plan": "enterprise"])
// Add global attributes to all signals
MoboreIosSdkAgent.addGlobalAttribute(key: "feature_flag", value: "new_checkout")

Use the .reportName() modifier to set meaningful screen names for SwiftUI views:

struct ProductDetailView: View {
var body: some View {
ScrollView { /* ... */ }
.reportName("ProductDetail")
}
}

The full documentation covers advanced topics including signal filtering, attribute interceptors, session management, data persistence, privacy manifests, and troubleshooting: