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:
- Create an iOS, tvOS, or macOS app in Real User Monitoring (RUM) and obtain the
RUM App ID. - Confirm the reporting address and authentication method:
- Local environment deployment: Prepare
datakitUrl - Public DataWay: Prepare
datawayUrlandclientToken - Confirm that the SDK has been installed in the project;
Swift Package Manageris recommended, andCocoaPodsandCarthageare also supported.
Integration Steps¶
- Install
GuanceSDKin the project. - Initialize
FTSDKConfigwhen the app starts. - Initialize
FTRumConfigand enable collection of View, Action, Resource, crashes, and freezes. - Enable debug logs, run the app, and trigger a page view or network request.
- 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:)withinitWithDatakitUrl:/FTSDKConfig(datakitUrl:).FTMobileConfigis still supported for compatibility, but new code should useFTSDKConfig. 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¶
- Keep
enableSDKDebugLog = YES/trueenabled, and run the app. - Open a page or initiate a
URLSessionnetwork request. - In the Xcode console, confirm that logs related to SDK initialization and data synchronization appear.
- 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¶
- For complete installation and initialization instructions, continue reading App Integration.
- To upgrade from a version earlier than 1.6.6, read the Migration Guide.
- For descriptions of all initialization parameters, read SDK Initialization.
- For detailed RUM, Log, and Trace configuration, read RUM Configuration, Log Configuration, and Trace Configuration.
- To integrate WebView monitoring, read WebView Data Monitoring.
- To integrate Session Replay, read iOS Session Replay.