Skip to main content

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:

  1. HTTP requests, using URLSession instrumentation
  2. Unhandled exceptions (NSException, NSError, Error)
  3. Custom Logs
  4. Crashes - using PLCrashReporter
  5. Page navigation (Swift use swizzling / SwiftUI use modifier)
  6. User Actions (Clicks - UI elements)
  7. ANR (Application Not Responding) detection
  8. 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

  1. Open File > Add Package Dependencies.
  2. Search for git@github.com:coralogix/cx-ios-sdk.
  3. 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/:

AppTargetDescription
DemoAppSwiftUIKitReference implementation — all instrumentation scenarios
DemoAppSwiftUISwiftUISwiftUI 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:

  1. Open Example/DemoApp.xcworkspace in Xcode.
  2. Select the DemoAppSwift or DemoAppSwiftUI scheme.
  3. Fill in your credentials in Example/Shared/Envs.swift (API key, proxy URL).
  4. 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.

Last updated on
On this page
Was this page helpful?