Install the Splunk RUM iOS agent

Instrument your iOS applications for Splunk Observability Cloud real user monitoring / RUM using the iOS RUM library from the Splunk OpenTelemetry Instrumentation for iOS.

To instrument a new iOS application with the new Splunk RUM agent, follow the instructions on this page. If you're already instrumenting the application with the 0.13.0 or lower version of the Splunk RUM, follow the instructions on Upgrade the Splunk RUM iOS agent instead.

Note: Splunk APM is not required to instrument Splunk RUM for iOS.

Decide which version to run in your environment

Latest updates automatically whenever Splunk RUM releases a new version. In pre-production, use latest to try out the most recent version of Splunk RUM. In production environments, use the pinned version which was previously tested in pre-production and update the production version on a monthly cycle.

Check compatibility and requirements

Splunk RUM for Mobile supports the following versions:

  • iOS 15 and higher

  • iPadOS 15 and higher

Generate customized instructions using the guided setup

Before you instrument and configure Splunk RUM for your iOS application, understand which data RUM collects about your application and determine the scope of what you want to monitor. See Data collected by Splunk RUM.

Tip: To generate all the basic installation commands for your environment and application, use the iOS Instrumentation guided setup.

To access the iOS Instrumentation guided setup, follow these steps:

  1. Log in to Splunk Observability Cloud.

  2. In the navigation menu, select Data Management.

  3. Go to the Available integrations tab, or select Add Integration in the Deployed integrations tab.

  4. In the integration filter menu, select By Use Case.

  5. Select the Monitor user experience use case.

  6. Select the iOS Instrumentation tile to open the iOS Instrumentation guided setup.

Install the Splunk RUM agent manually

To install the iOS RUM library using Swift Package Manager, follow these steps:

  1. In Xcode, Add a dependency to the Splunk RUM package, SplunkAgent, in Swift package manager (SPM):

    1. In Xcode, select File > Add Packages... or File > Swift Packages > Add Package Dependency, and enter the following URL in the search bar:

      https://github.com/signalfx/splunk-otel-ios
    2. Select Dependency Rule Exact Version and change the version to 2.0.0.

    3. Select Add Package to install the package.

  2. Initialize the Splunk RUM package, SplunkAgent

    1. Include following code snippet in AppDelegate.swift or @main Content file in your application:

      Swift
      import SplunkAgent
      
      
      let endpointConfiguration = EndpointConfiguration(
          realm: "YOUR_REALM",
          rumAccessToken: "YOUR_RUM_ACCESS_TOKEN"
      )
      
      let agentConfiguration = AgentConfiguration(
          endpoint: endpointConfiguration,
          appName: "YOUR_APP_NAME",
          deploymentEnvironment: "YOUR_DEPLOYMENT_ENVIRONMENT"
      )
      
      var agent: SplunkRum?
      
      do {
          agent = try SplunkRum.install(with: agentConfiguration)
      } catch {
          print("Unable to start the Splunk agent, error: \(error)")
      }
      
      // Example: Enable automated navigation tracking
      agent?.navigation.preferences.enableAutomatedTracking = true
      
      // Example: Start session replay
      agent?.sessionReplay.start()
      Objective-C
      @import SplunkAgentObjC;
      
      
      SPLKEndpointConfiguration* endpointConfiguration = [[SPLKEndpointConfiguration alloc] initWithRealm:@"<YOUR_REALM>" rumAccessToken:@"YOUR_RUM_ACCESS_TOKEN"];
      
      SPLKAgentConfiguration* agentConfiguration = [[SPLKAgentConfiguration alloc] initWithEndpoint:endpointConfiguration appName:@"YOUR_APP_NAME" deploymentEnvironment:@"YOUR_DEPLOYMENT_ENVIRONMENT"];
          
      NSError* error = nil;
      SPLKAgent* agent = [SPLKAgent installWith:agentConfiguration error:&error];
      
      if (agent == nil) {
          NSLog(@"Unable to start the Splunk agent, error: %@", [error description]);
      } else {
          // Example: Start session replay
          [[agent sessionReplay] start];
      }
    2. Deploy the changes to your application.

Disable crash reporting

The crash reporting module is included in the new Splunk RUM agent and is enabled by default. No additional steps are needed to activate crash reporting. If you want to deactivate crash reporting, include the following code snippet in AppDelegate.swift or in the @main Content file in your application:

import SplunkCrashReports

// Disable configuration for crash reporting
let crashReportsConfig = SplunkCrashReports.CrashReportsConfiguration(isEnabled: false)

// Initialize the configuration of the Agent
let agentConfig = AgentConfiguration(endpoint: .init(realm: "your-realm", rumAccessToken: "your-rum-access-token"), 
                appName: "your-app-name", 
                deploymentEnvironment: "deployment-environment")

// Specify crash module configuration during agent installation
let agent: SplunkRum = try SplunkRum.install(with: agentConfig, moduleConfigurations: [crashReportsConfig])
Note: https://github.com/signalfx/splunk-otel-ios-crashreporting will be deprecated in the future.

Splunk RUM uses server timing to calculate the response time between the front end and back end of your application, and to join the front-end and back-end traces for end-to-end visibility.

By default, the Splunk Distributions of OpenTelemetry already send the Server-Timing header. The header links spans from the browser with back-end spans and traces.

The APM environment variable for controlling the Server-Timing header is SPLUNK_TRACE_RESPONSE_HEADER_ENABLED. Set SPLUNK_TRACE_RESPONSE_HEADER_ENABLED=true to link to Splunk APM.

Instrument iOS WebViews using the Browser RUM library

You can use Mobile RUM instrumentation and Browser RUM instrumentation simultaneously to see RUM data combined in one stream. You can do this by sharing the session.id between both instrumentations.

The following Swift snippet shows how to integrate iOS RUM with Splunk Browser RUM:

import WebKit
import SplunkAgent
 
...
/*
Make sure that the WebView instance only loads pages under
your control and instrumented with Splunk Browser RUM. The
integrateWithBrowserRum() method can expose the session.id
of your user to every site/page loaded in the WebView instance.
*/
let webview: WKWebView = ...
SplunkRum.shared.webViewNativeBridge.integrateWithBrowserRum(webView)

Change attributes before they’re collected

To remove or change attributes in your spans, such as personally identifiable information (PII), see Filter spans.

How to contribute

The Splunk OpenTelemetry Instrumentation for iOS is open-source software. You can contribute to its improvement by creating pull requests in GitHub. To learn more, see the contributing guidelines in GitHub.

Next steps