Skip to content

Quick Start

This document provides the shortest integration path for the iOS/tvOS/macOS RUM SDK to help you complete a verifiable data reporting process with minimal steps.

The app supports Agent auto-integration and manual integration. The following steps describe the minimum configuration for manual integration.

Prerequisites

The minimum deployment targets for SDK 1.6.8+ are iOS 15, tvOS 15, and macOS 12. To upgrade an existing project, first see 1.6.8 Upgrade Requirements.

Before you begin, complete the following preparations:

  1. Create an iOS, tvOS, or macOS app in Real User Monitoring (RUM) and obtain the RUM App ID.
  2. Confirm the reporting address and authentication method:
  3. Local environment deployment: Prepare datakitUrl
  4. Public DataWay: Prepare datawayUrl and clientToken
  5. Confirm that the SDK has been installed in the project; Swift Package Manager is recommended, and CocoaPods and Carthage are also supported.

Integration Steps

  1. Install GuanceSDK in the project.
  2. Initialize FTSDKConfig when the app starts.
  3. Initialize FTRumConfig and enable collection of View, Action, Resource, crashes, and freezes.
  4. Enable debug logs, run the app, and trigger a page view or network request.
  5. Confirm in the console and on the Guance platform that the data has been reported successfully.

Install the SDK

For installation methods, refer directly to App Integration.

If you only want to verify quickly, prefer Swift Package Manager; choose CocoaPods or Carthage only when existing dependency management constraints require it.

Minimal Initialization Example

On iOS/tvOS, initialization is usually performed in the AppDelegate. On macOS, the viewDidLoad method of the first displayed NSViewController and the windowDidLoad method of the NSWindowController are called before the AppDelegate's applicationDidFinishLaunching. To avoid abnormal lifecycle collection for the first view, initialize the SDK in main.m or main.swift.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // For local environment deployment, use [[FTSDKConfig alloc] initWithDatakitUrl:datakitUrl]
    FTSDKConfig *config = [[FTSDKConfig alloc] initWithDatawayUrl:datawayUrl clientToken:clientToken];
    config.enableSDKDebugLog = YES;
    [FTMobileAgent startWithConfigOptions:config];

    FTRumConfig *rumConfig = [[FTRumConfig alloc] initWithAppid:appid];
    rumConfig.enableTraceUserView = YES;
    rumConfig.enableTraceUserAction = YES;
    rumConfig.enableTraceUserResource = YES;
    rumConfig.enableTrackAppFreeze = YES;
    rumConfig.enableTrackAppCrash = YES;
    rumConfig.enableTrackAppANR = YES;
    [[FTMobileAgent sharedInstance] startRumWithConfigOptions:rumConfig];
    return YES;
}
// main.m file
#import <Cocoa/Cocoa.h>
#import <GuanceSDK/GuanceSDK.h>
int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // For local environment deployment, use [[FTSDKConfig alloc] initWithDatakitUrl:datakitUrl]
        FTSDKConfig *config = [[FTSDKConfig alloc] initWithDatawayUrl:datawayUrl clientToken:clientToken];
        config.enableSDKDebugLog = YES;
        [FTSDKAgent startWithConfigOptions:config];

        FTRumConfig *rumConfig = [[FTRumConfig alloc] initWithAppid:appid];
        rumConfig.enableTraceUserView = YES;
        rumConfig.enableTraceUserAction = YES;
        rumConfig.enableTraceUserResource = YES;
        rumConfig.enableTrackAppFreeze = YES;
        rumConfig.enableTrackAppCrash = YES;
        rumConfig.enableTrackAppANR = YES;
        rumConfig.errorMonitorType = FTErrorMonitorAll;
        rumConfig.deviceMetricsMonitorType = FTDeviceMetricsMonitorAll;
        [[FTSDKAgent sharedInstance] startRumWithConfigOptions:rumConfig];
    }
    return NSApplicationMain(argc, argv);
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // For local environment deployment, use FTSDKConfig(datakitUrl: datakitUrl)
    let config = FTSDKConfig(datawayUrl: datawayUrl, clientToken: clientToken)
    config.enableSDKDebugLog = true
    FTMobileAgent.start(withConfigOptions: config)

    let rumConfig = FTRumConfig(appid: appid)
    rumConfig.enableTraceUserView = true
    rumConfig.enableTraceUserAction = true
    rumConfig.enableTraceUserResource = true
    rumConfig.enableTrackAppFreeze = true
    rumConfig.enableTrackAppCrash = true
    rumConfig.enableTrackAppANR = true
    FTMobileAgent.sharedInstance().startRum(withConfigOptions: rumConfig)
    return true
}
import Cocoa
import GuanceSDK
let delegate = AppDelegate()
NSApplication.shared.delegate = delegate

// For local environment deployment, use FTSDKConfig(datakitUrl: datakitUrl)
let config = FTSDKConfig(datawayUrl: datawayUrl, clientToken: clientToken)
config.enableSDKDebugLog = true
FTSDKAgent.start(withConfigOptions: config)

let rumConfig = FTRumConfig(appid: appid)
rumConfig.enableTraceUserView = true
rumConfig.enableTraceUserAction = true
rumConfig.enableTraceUserResource = true
rumConfig.enableTrackAppFreeze = true
rumConfig.enableTrackAppCrash = true
rumConfig.enableTrackAppANR = true
rumConfig.errorMonitorType = .all
rumConfig.deviceMetricsMonitorType = .all
FTSDKAgent.sharedInstance().startRum(withConfigOptions: rumConfig)

_ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)

When using Swift, create a main.swift file first and remove @main or @NSApplicationMain from AppDelegate.swift.

The examples above meet the minimum RUM integration requirements and enable crash and freeze detection by default. If you use a local environment deployment, replace initWithDatawayUrl:clientToken: / FTSDKConfig(datawayUrl:clientToken:) with initWithDatakitUrl: / FTSDKConfig(datakitUrl:). FTMobileConfig is still supported for compatibility, but new code should use FTSDKConfig. macOS is currently in Alpha, and not all iOS features are guaranteed to be supported.

Optional: Initialize Log and Trace

If you also need Log Collection or Distributed Tracing, you can add the following initialization:

FTLoggerConfig *loggerConfig = [[FTLoggerConfig alloc] init];
loggerConfig.enableCustomLog = YES;
loggerConfig.enableLinkRumData = YES;
[[FTMobileAgent sharedInstance] startLoggerWithConfigOptions:loggerConfig];

FTTraceConfig *traceConfig = [[FTTraceConfig alloc] init];
traceConfig.enableAutoTrace = YES;
traceConfig.enableLinkRumData = YES;
[[FTMobileAgent sharedInstance] startTraceWithConfigOptions:traceConfig];
let loggerConfig = FTLoggerConfig()
loggerConfig.enableCustomLog = true
loggerConfig.enableLinkRumData = true
FTMobileAgent.sharedInstance().startLogger(withConfigOptions: loggerConfig)

let traceConfig = FTTraceConfig()
traceConfig.enableAutoTrace = true
traceConfig.enableLinkRumData = true
FTMobileAgent.sharedInstance().startTrace(withConfigOptions: traceConfig)

Verify the Integration

  1. Keep enableSDKDebugLog = YES/true enabled, and run the app.
  2. Open a page or initiate a URLSession network request.
  3. In the Xcode console, confirm that logs related to SDK initialization and data synchronization appear.
  4. Return to the Guance console and confirm that the corresponding RUM data has appeared for the app.

If you need further troubleshooting, see Troubleshooting.

Next Steps

Feedback

Is this page helpful?