All Products
Search
Document Center

:Integrate an iOS app into RUM through Xcode

Last Updated:Aug 12, 2024

The Real User Monitoring (RUM) sub-service of Application Real-Time Monitoring Service (ARMS) provides comprehensive monitoring capabilities for iOS apps and Android apps. This topic describes how to integrate an iOS app into RUM through Xcode.

Step 1: Add the app and obtain the OpenRUM SDK

  1. Log on to the ARMS console.
  2. In the left-side navigation pane, choose User Experience Monitoring > Application List. In the top navigation bar, select a region.

  3. On the Applications page, click Add Application.

  4. In the Create Application panel, click iOS.

  5. In the iOS panel, enter the app name and description, and click Create.

    Note

    The name must be unique.

    Then, an address to which monitoring data is reported (ConfigAddress) and an app ID (AppID) are automatically generated for the app.

  6. Download the installation package of the OpenRUM SDK and decompress the package.

    The following figure shows the files of the OpenRUM SDK.

    image.png

Step 2: Integrate the OpenRUM SDK into the project

  1. Move the OpenRUM.framework file from the ios-arm64_armv7_armv7s or ios-arm64_i386_x86_64-simulator folder to the directory of the Xcode project based on whether you are using a simulator or not.

    • ios-arm64_armv7_armv7s: real computer

    • ios-arm64_i386_x86_64-simulator: simulator

  2. Configure the settings and click Finish.

    image.png

    View the added OpenRUM dependencies in the file navigator sidebar.

    image.png

  3. In the Link Binary With Libraries section of the Build Phases tab, add the OpenRUM.framework file and the following libraries.

    • libresolv.tbd. Required.

    • libc++.tbd. Required.

    • webKit.framework. Add the library if the project supports iOS versions earlier than 8.

    image.png

  4. Search for the Other Linker Flags setting on the Build Settings tab and add the -ObjC flag.

    image.png

Step 3: Initialize the OpenRUM SDK

Important

You must enter the code in sequence. Otherwise, the SDK fails to be initialized.

Objective-C

  1. Introduce the header file to the main.m or AppDelegate.m file.

    #import <OpenRUM/OpenRUM.h>
  2. Initialize the OpenRUM SDK in the main function or the - application:didFinishLaunchingWithOptions: method.

    Note

    Replace Address and appId in the following code with the address and app ID obtained from the ARMS console.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        [OpenRUM setConfigAddress:@"Address"]; // Specify the address.
        [OpenRUM startWithAppID:@"appId"]; 
      	[OpenRUM setUserID:@"user-id"]; // Optional. Specify the username. 
        return YES;
    }
  3. If SDK Config Succeeded is returned after the preceding code is executed, the SDK has been initialized.

    Sample output:

    2023-07-31 16:07:18.450 [OpenRUM] [CONFIG]  SDK Config Succeeded.
    Note

    We recommend that you initialize the SDK in the main function because it can completely capture the startup duration and the time consumption details of the - application didFinishLaunchingWithOptions method and the internal methods. Otherwise, only the startup duration is captured when the agent is running.

Swift

  1. Introduce the header file to the Bridging Header file.

    #import <OpenRUM/OpenRUM.h>
  2. Configure the following code in the AppDelegate.swift file.

    Note

    Replace Address and appId in the following code with the address and app ID obtained from the ARMS console.

    class AppDelegate: UIResponder, UIApplicationDelegate {
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            OpenRUM.setConfigAddress("Address") // Specify the address.
            OpenRUM.start(withAppID: "appId")
          	OpenRUM.setUserID("user-id") // Optional. Specify the username. 
            return true
        }
    }
  3. If SDK Config Succeeded is returned after the preceding code is executed, the SDK has been initialized.

    Sample output:

    2023-07-31 16:07:18.450 [OpenRUM] [CONFIG] SDK Config Succeeded.