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
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)
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' endIn 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
Download the SDK and extract the .zip file.
The extracted .zip file contains the following:
AlibabaCloudRUM.xcframework
AlibabaCloudRUMSDK.xcframework
Configure the project.
In Xcode, choose . In the panel, select the two framework packages from the previous step, and then click Add.
NoteThe 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.
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.
In target > Build Settings, search for Other Linker Flags and add the
-ObjClinker flag.ImportantMake sure that
-ObjCis 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 AlibabaCloudRUMStep 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