---
title: tvOS
description: This guide provides instructions for integrating the Coralogix RUM SDK into tvOS applications for UIKit and SwiftUI projects. It also details the configuration options, logging functionalities, and best practices for using method swizzling and SwiftUI modifiers to monitor and analyze app performance and user interactions.
url: https://coralogix.com/docs/user-guides/rum/sdk-installation/apple/tvos/
product: rum
feature: iOS SDK
feature_id: mobile-sdk-ios
feature_identifier: rum/mobile-sdk-ios
last_updated: '2026-10-27'
---

# tvOS

This guide provides instructions for integrating the Coralogix RUM SDK into tvOS applications for UIKit and SwiftUI projects. It also details the configuration options, logging functionalities, and best practices for using method swizzling and SwiftUI modifiers to monitor and analyze app performance and user interactions.

## What you need

* **tvOS**: ver. 14 or above

* **Swift**: ver. 5.9 or above

* **Xcode**: ver. 14 or above

* **RUM key**: a Send-Your-Data key with the **SendRUMData** role preset. [Create it](https://coralogix.com/docs/user-guides/account-management/api-keys/api-keys.md#create-an-api-key) before the setup below. The key is public, and the preset is standalone, so it can't be combined with other presets. Don't use **SendData**: it carries no RUM permissions, and keys created with it must stay secret, so they don't belong in client code.

## Features

In addition to capturing HTTP requests (instrumentation using `URLSession`), this SDK can intercept the following telemetry data:

* Unhandled exceptions, including `NSException`, `NSError`, and `Error`.

* Custom logs.

* Crashes, using `PLCrashReporter`.

* Page navigation, using method swizzling for UIKit and modifiers for SwiftUI.

## Installation

To add the Coralogix SDK to your project using 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.

## Initialization

Call the SDK as early in your application lifecycle as possible, ideally in `applicationDidFinishLaunching` in `AppDelegate`.

Select the features to include, and the code samples below update to match.

RUM\[ ]Tracing\[ ]Session sampling

### UIKit (AppDelegate)

1. Use the following code.

```
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: domain,

            userContext: nil,

            environment: "ENVIRONMENT",

            application: "APP-NAME",

            version: "APP-VERSION",

            publicKey: "API-KEY",

            ignoreUrls: [],

            ignoreErrors: [],

            customDomainUrl: nil,

            labels: ["item": "playstation 5", "itemPrice": 1000],

            debug: false

        )

        self.coralogixRum = CoralogixRum(options: options)

        return true

    }

}
```

### SwiftUI

Create a SwiftUI project to use Coralogix in your app. It's required if the Swift UI doesn't include `AppDelegate` or `SceneDelegate` files.

1. Use the following code.

```
import SwiftUI

import Coralogix



@main

struct DemoAppApp: App {

    @State private var coralogixRum: CoralogixRum



    init() {

			let domain = CoralogixDomain.US2

			let options = CoralogixExporterOptions(

            coralogixDomain: domain,

            userContext: nil,

            environment: "ENVIRONMENT",

            application: "APP-NAME",

            version: "APP-VERSION",

            publicKey: "TOKEN",

            ignoreUrls: [],

            ignoreErrors: [],

            customDomainUrl: nil,

            labels: ["item": "playstation 5", "itemPrice": 1000],

            debug: false

        )

        self.coralogixRum = CoralogixRum(options: options)

    }



    var body: some Scene {

        WindowGroup {

            ContentView(coralogixRum: $coralogixRum)

        }

    }

}
```

Refer to the following fields for `CoralogixExporterOptions`.

| Property        | Type            | Description                                                                                                                  | Required |
| --------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------- | -------- |
| userContext     | UserContext?    | Configuration for user context.                                                                                              | No       |
| debug           | Bool            | Turns on/off internal debug logging.                                                                                         | No       |
| ignoreUrls      | \[String]?      | URLs that partially match any regex in ignoreUrls will not be traced.                                                        | No       |
| ignoreErrors    | \[String]?      | A pattern for error messages which should not be sent to Coralogix.                                                          | No       |
| coralogixDomain | CoralogixDomain | Coralogix [Coralogix domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain.md) | Yes      |
| publicKey       | String          | Coralogix token, publicly-visible public\_key value. This is a required property.                                            | Yes      |
| environment     | String          | Specifies the environment, such as development, staging, or production.                                                      | Yes      |
| application     | String          | Name of the application                                                                                                      | Yes      |
| version         | String          | Version of the application                                                                                                   | Yes      |
| customDomainUrl | String?         | Ignores CoralogixDomain URL and routes all data calls to a specific URL.                                                     | No       |
| labels          | \[String: Any]? | Sets labels that are added to every span.                                                                                    | No       |

## Instrumentation

Enable or disable specific instrumentation (see the list below), with the default set to all trues. Each instrumentation controls the data the SDK will track and collect.

* **mobileVitals** – Automatically detects and monitors key performance metrics related to application responsiveness and rendering performance. This allows developers to track vital aspects of the app's user experience and performance without manual intervention. The SDK currently supports automatic detection of the following metrics: Frames Per Second (FPS), Warm Start, Cold Start.

* **ANR** – Automatically detects Application Not Responsive (ANR) metric.

* **navigation** – Identifies user movement between pages (ViewController call) while extracting the view name.

* **custom** – Allows developers to define and track custom events, giving insights into specific actions or behaviors in the application that are critical to the business.

* **errors** – Captures JavaScript errors, network errors, and other issues in the application. This data helps diagnose and resolve bugs or failures that affect the user experience.

* **network** – Monitors all network calls.

* **userActions** – Catches user actions, such as button clicks, tab activations, and other navigation controllers. It creates a span with a severity level of `info` and an event type of `user-interaction`, incorporating details about the element, including the text displayed on it.

* **appLifeCycle** – Captures app lifecycle events that occur during runtime, providing insights into the application's behavior and performance.

  * **application(\_:didFinishLaunchingWithOptions:)** – Called after the app has launched, this is where you establish the initial app state, including setting up the user interface and restoring previous sessions.

  * **applicationDidBecomeActive(\_:)** – Called when the app becomes active and is ready for user interaction, this is the ideal moment to restart any tasks that were paused or not yet initiated.

  * **applicationDidEnterBackground(\_:)** – Called when the app is about to move from the foreground to the background. This is where you should release shared resources, save user data, and store enough app state to restore the app to its current state if it's terminated later.

  * **applicationWillTerminate(\_:)** – Called when the app is about to terminate, this is your final opportunity to save data and release any resources.

  * **applicationDidReceiveMemoryWarning(\_:)** – Called when the app receives a memory warning from the system, this is the time to release any non-essential memory to ensure your app continues to run smoothly.

  * **application(\_:open:options:)** – Called when the app is requested to open a URL, typically from another app, this allows you to manage deep linking and facilitate inter-app communication.

  * **application(\_:didReceiveRemoteNotification:fetchCompletionHandler:)** – Called when a remote notification is received, this provides your app an opportunity to fetch new content in the background. This function cannot be called automatically. Use the custom log API to initiate it. All events will arrive to the Coralogix as an `info` log type and the message field will be the event itself (`appDidBecomeActiveNotification`). For example,

```
public func log(severity: CoralogixLogSeverity,

          message: String,

          data: [String: Any]? = nil) {

    if CoralogixRum.isInitialized {

      self.logWith(severity: severity, message: message, data: data)

    }

  }
```

### Example

```
let options = CoralogixExporterOptions(coralogixDomain: CoralogixDomain.US2,

                                               userContext: nil,

                                               environment: "ENVIRONMENT",

                                               application: "APP-NAME",

                                               version: "APP-VERSION",

                                               publicKey: "TOKEN",

                                               ignoreUrls: [], //[".*\\.il$", "https://www.coralogix.com/academy"],

                                               ignoreErrors: [], //[".*errorcode=.*", "Im cusom Error"],

                                               customDomainUrl: nil,

                                               labels: [:],

                                               instrumentations: [.navigation: false,

                                                                  .mobileVitals: false,

                                                                  .custom: true,

                                                                  .errors: true,

                                                                  .userActions: true,

                                                                  .network: true,

                                                                  .lifeCycle: true],

                                               debug: false)
```

## Integration functions

This section lists public functions used to interact with the Coralogix exporter.

### Set user context

#### Example

```
public func setUserContext(userContext: UserContext)
```

### Set labels

#### Example

```
public func set(labels: [String: Any])
```

### Report errors

Report a handled error to Coralogix. Each overload takes optional `data` and `labels` dictionaries, so you can attach structured context and event labels in the same call instead of pairing `reportError` with a separate [`log`](#log-messages).

```
public func reportError(exception: NSException, data: [String: Any]? = nil, labels: [String: Any]? = nil)

public func reportError(error: NSError, data: [String: Any]? = nil, labels: [String: Any]? = nil)

public func reportError(error: Error, data: [String: Any]? = nil, labels: [String: Any]? = nil)

public func reportError(message: String, data: [String: Any]? = nil, labels: [String: Any]? = nil)
```

* `data`: Structured key-value context attached to the error event under `error_context.error_custom_data`.
* `labels`: Key-value labels merged into the error event's labels, so you can filter and group errors by them in Coralogix.

Provide JSON-serializable values (strings, numbers, booleans, and arrays or nested dictionaries of those). Values that cannot be represented in JSON, such as `Date` or class instances, may be dropped, convert them first, for example by using an ISO 8601 string for a date.

#### Example

```
let error = NSError(domain: "PaymentError", code: 1001)



// Report a handled error.

CoralogixRum.reportError(error: error)



// Attach structured data.

CoralogixRum.reportError(

    error: error,

    data: ["orderId": "ORD-123", "amount": 99.99]

)



// Attach structured data and labels.

CoralogixRum.reportError(

    error: error,

    data: ["orderId": "ORD-123", "amount": 99.99],

    labels: ["team": "payments", "severity": "high"]

)
```

### Log messages

Send log messages with customized severity levels.

#### Example

```
public func log(severity: CoralogixLogSeverity, message: String, data: [String: Any]?)
```

The `CoralogixLogSeverity` defines severity levels for logs in the Coralogix system.

| Case     | Raw Value | Severity       |
| -------- | --------- | -------------- |
| debug    | 1         | Debug-level    |
| verbose  | 2         | Verbose-level  |
| info     | 3         | Informational  |
| warn     | 4         | Warning-level  |
| error    | 5         | Error-level    |
| critical | 6         | Critical-level |

#### Example

```
coralogixRUM.log(severity: .error, message: "An error occurred in the application.", data: nil)
```

### Shut down the exporter

Shut down the Coralogix exporter and mark it as uninitialized.

#### Example

```
public func shutdown()
```

## Method swizzling and SwiftUI modifiers

Use these best practices to dynamically alter the behavior of existing methods at runtime in Swift and Objective-C.

* **Method Swizzling**: A technique used in Objective-C and Swift to change the implementation of an existing selector at runtime. Use it for injecting custom behavior without altering the original code.

* **SwiftUI Modifiers**: A declarative and safe approach to modifying views through view modifiers, providing better readability and maintainability.

In addition, using `CXViewModifier` and `trackCXView` method, you can add custom behavior to views in a SwiftUI-friendly way.

### Example

```
import SwiftUI



struct ContentView: View {

    var body: some View {

        Text("Hello, World!")

            .trackCXView(name: "ContentView")

    }

}
```

## Limitations

* **Session Replay is not supported on tvOS.** The Session Replay engine is iOS-only. tvOS apps capture errors, network calls, custom logs, and Mobile Vitals through the base SDK.
