Official Coralogix SDK for iOS
Overview
The Coralogix RUM Mobile SDK is a library for iOS, distributed through Swift Package Manager and CocoaPods. The SDK provides mobile Telemetry instrumentation that captures:
- HTTP requests, using URLSession instrumentation
- Unhandled exceptions (NSException, NSError, Error)
- Custom Logs
- Crashes - using PLCrashReporter
- Page navigation (Swift use swizzling / SwiftUI use modifier)
- User Actions (Clicks - UI elements)
- ANR (Application Not Responding) detection
- Mobile Vitals (FPS, CPU, Memory, Cold Start, Warm Start, Slow/Frozen Frames)
Requirements
Coralogix RUM agent for iOS supports iOS 13 and higher.
Installation
The integration requires minimal effort with a few lines of code. The SDK can be installed with Swift Package Manager or CocoaPods.
Swift Package Manager
- Open File > Add Package Dependencies.
- Search for
git@github.com:coralogix/cx-ios-sdk. - Select the Up to Next Major Version option.
CocoaPods
Add the Coralogix pod to your Podfile:
pod 'Coralogix'
pod 'SessionReplay' # Only if you use Session Replay
Then run pod install from your project root.
Initialization
Remember to call this as early in your application life cycle as possible.
Ideally in applicationDidFinishLaunching in your AppDelegate
import UIKit
import Coralogix
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var coralogixRum: CoralogixRum?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let domain = CoralogixDomain.US2
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY")
self.coralogixRum = CoralogixRum(options: options)
return true
}
Or if you are using swiftUI
import SwiftUI
import Coralogix
@main
struct DemoAppApp: App {
@State private var coralogixRum: CoralogixRum
init() {
let domain = CoralogixDomain.US2
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY")
self.coralogixRum = CoralogixRum(options: options)
}
var body: some Scene {
WindowGroup {
ContentView(coralogixRum: $coralogixRum)
}
}
}
Example Apps
The repository includes two fully-featured demo apps under Example/:
| App | Target | Description |
|---|---|---|
DemoAppSwift | UIKit | Reference implementation — all instrumentation scenarios |
DemoAppSwiftUI | SwiftUI | SwiftUI port — same scenarios, native SwiftUI patterns |
Both apps cover: Network instrumentation, Error instrumentation, SDK functions, Custom spans, User Actions (tap/scroll/swipe), Session Replay, Traces Exporter, Schema Validation, Mask UI, and Clock.
To run locally:
- Open
Example/DemoApp.xcworkspacein Xcode. - Select the
DemoAppSwiftorDemoAppSwiftUIscheme. - Fill in your credentials in
Example/Shared/Envs.swift(API key, proxy URL). - Run on a simulator or device.
E2E UI tests (requires a running validation proxy):
# UIKit
xcodebuild test \
-workspace Example/DemoApp.xcworkspace \
-scheme DemoAppSwift \
-destination 'platform=iOS Simulator,name=iPhone 16,OS=18.5' \
-only-testing:DemoAppUITests
# SwiftUI
xcodebuild test \
-workspace Example/DemoApp.xcworkspace \
-scheme DemoAppSwiftUI \
-destination 'platform=iOS Simulator,name=iPhone 16,OS=18.5' \
-only-testing:DemoAppSwiftUIUITests
License
This project is licensed under the MIT License - see the LICENSE file for details.