All Products
Search
Document Center

Application Real-Time Monitoring Service:Integrate an iOS application

Last Updated:Aug 20, 2026

Real User Monitoring (RUM) provides comprehensive monitoring for mobile applications, letting you monitor and analyze key metrics such as application performance, crashes, and freezes. Follow this guide to integrate an iOS application.

Upgrade notes

Important

The SDK integration parameters changed in version 2.0.0 and are not backward-compatible. If you upgrade to version 2.0.0 or later, follow the latest integration documentation to ensure the SDK is properly initialized.

Step 1: Integrate an SDK

CocoaPods (recommended)

  1. Add the latest version of the SDK to the Podfile in your Xcode project.

    source 'https://github.com/CocoaPods/Specs.git'
    
    target 'iOSDemo' do
      # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
      use_frameworks!
    
      # Import the Alibaba Cloud RUM SDK
      pod 'AlibabaCloudRUM', '2.4.0'
    end
  2. In your project's root directory, or the directory where the Podfile is located, run the following command to update the CocoaPods environment.

    pod install --repo-update

Manual integration

  1. Download the SDK and extract the .zip file.

    The extracted .zip file contains the following:

    • AlibabaCloudRUM.xcframework

    • AlibabaCloudRUMSDK.xcframework

  2. Configure the project.

    1. In Xcode, choose File > Add Files to "Your Project Name".... In the panel, select the two framework packages from the previous step, and then click Add.

      Note
      • The user interface may vary slightly depending on your Xcode version.

      • We recommend that you select Copy files to destination.

      In the Targets section, select the target for your project, such as iOSDemo, and then click Finish.

    2. In your project settings, navigate to target > Build Phases > Link Binary With Libraries and add the following dependency libraries:

      • libc++.tbd (Required)

      • libresolv.tbd (Required)

      In your Xcode project, navigate to Build Phases > Link Binary With Libraries and confirm that the preceding system libraries, AlibabaCloudRUMSDK.xcframework, and AlibabaCloudRUM.xcframework have been added. Ensure that the Status for each is set to Required.

    3. In target > Build Settings, search for Other Linker Flags and add the -ObjC linker flag.

      Important

      Make sure that -ObjC is spelled correctly.

Step 2: Import a header file

In the main.m or AppDelegate.m file, import the header file.

Objective-C

@import AlibabaCloudRUM;

Swift

import AlibabaCloudRUM

Step 3: Initialize the SDK

Initialize the SDK in the main function or the - application:didFinishLaunchingWithOptions: method.

Objective-C

// [Recommended] Enable the Session Replay module.
[AlibabaCloudRUM enableModule:AlibabaCloudModuleSessionReplay];

// [Required] Obtain the endpoint when you create a RUM application.
[AlibabaCloudRUM setEndpoint:@"<your endpoint>"];
// [Required] Obtain the workspace when you create a RUM application.
[AlibabaCloudRUM setWorkspace:@"<your workspace>"];
// [Required] Obtain the serviceId when you create a RUM application.
[AlibabaCloudRUM start:@"<your serviceId>"];

// [Recommended] Configure Session Replay. The configuration includes:
// 1. A sample rate of 5%
// 2. Preservation of static text, placeholder text, and normal input
// 3. Preservation of built-in resource images
// 4. Recording of touch positions
AlibabaCloudSessionReplayConfiguration *sessionReplayConfiguration =
[AlibabaCloudSessionReplayConfiguration configurationWithSampleRate:5
                                                textAndInputPrivacy:AlibabaCloudTextAndInputPrivacyMaskSensitiveInputs
                                                       imagePrivacy:AlibabaCloudImagePrivacyMaskNonBundledOnly
                                                       touchPrivacy:AlibabaCloudTouchPrivacyShow];
// [Recommended] Start Session Replay data collection.
[AlibabaCloudSessionReplay startWithConfiguration:sessionReplayConfiguration];
// [Recommended] Enable the session replay module.
AlibabaCloudRUM.enableModule(.sessionReplay)

// [Required] Obtain the endpoint when you create a RUM application.
AlibabaCloudRUM.setEndpoint("<your endpoint>")
// [Required] Obtain the workspace when you create a RUM application.
AlibabaCloudRUM.setWorkspace:("<your workspace>")
// [Required] Obtain the serviceId when you create a RUM application.
AlibabaCloudRUM.start("<your serviceId>")

// [Recommended] Configure Session Replay with the following settings:
// 1. Sample rate: 5%
// 2. Retain static text, placeholder text, and regular input.
// 3. Retain built-in resource images.
// 4. Record touch positions.
let configuration = AlibabaCloudSessionReplayConfiguration(sampleRate: 5,
                                                           textAndInputPrivacy: .maskSensitiveInputs,
                                                           imagePrivacy: .maskNonBundledOnly,
                                                           touchPrivacy: .show)
// [Recommended] Start Session Replay data collection.
AlibabaCloudSessionReplay.start(configuration)

Swift

Step 4: Verify integration

After you run the application, check the console output. If the console displays "AlibabaCloudRUMSDK init success", the SDK initialized successfully. Example:

[AlibabaCloudRUM] [INFO   ] [RUM] <start> AlibabaCloud RUM init success