macOS Application Integration¶
Guance application monitoring can collect metrics data from various macOS applications and analyze the performance of macOS applications in a visualized manner.
Prerequisites¶
Note: If you have enabled the RUM Headless service, the prerequisites are automatically configured for you, and you can directly integrate the application.
- Install DataKit.
Application Integration¶
Log in to the Guance console, go to the User Analysis page, click on Create Application in the top-left corner, select Custom, and start creating a new application.
Installation¶
Source Code: https://github.com/GuanceCloud/datakit-macos
Demo: https://github.com/GuanceCloud/datakit-macos/Example
- Configure the
Podfile
.
- Run
pod install
in thePodfile
directory to install the SDK.
-
Select
PROJECT
->Package Dependency
, then click + under thePackages
tab. -
Enter
https://github.com/GuanceCloud/datakit-macos
in the search box that appears; this is the repository location. -
After Xcode successfully retrieves the package, it will display the SDK configuration page.
Dependency Rule
: It is recommended to choose Up to Next Major Version
.
Add To Project
: Select the supported project.
Click the Add Package
button after filling in the configurations and wait for it to complete loading.
- In the pop-up window
Choose Package Products for datakit-macos
, select the Target where you want to add the SDK, and click theAdd Package
button. The SDK has now been added successfully.
If your project is managed by SPM, add FTMacOSSDK as a dependency by adding dependencies
to Package.swift
.
Add Header Files¶
SDK Initialization¶
Basic Configuration¶
Since the viewDidLoad
method of the first displayed view NSViewController
and the windowDidLoad
method of NSWindowController
are called earlier than the applicationDidFinishLaunching
method of AppDelegate, to avoid abnormal lifecycle collection of the first view, it is recommended to initialize the SDK in the main.m
file.
```objectivec // main.m file
import "FTMacOSSDK.h"¶
int main(int argc, const char * argv[]) { @autoreleasepool { // Local environment deployment, DataKit deployment FTSDKConfig *config = [[FTSDKConfig alloc]initWithDatakitUrl:datakitUrl]; // Public DataWay deployment //FTSDKConfig *config = [[FTSDKConfig alloc📐📐📐
📐📐📐📐📐📐📐📐