Mac Platform Integration Guidelines
1 CrashSight Integration on MacOS
2 Mac SDK Integration
- After creating a project on the platform, the SDK that matches the platform and engine of the project can be downloaded from the "Tutorial" in the sidebar, as shown in the figure below:
- Drag the CrashSight.framework file into the Xcode project (Select "Copy items if needed")
2.1 SDK Initialization
2.1.1 Objective-C Initialization
-
Import header file
#import <CrashSight/CrashSight.h>
in the project's AppDelegate.m file -
Initialization: Initialize in the
application:didFinishLaunchingWithOptions:
method of the project's AppDelegate.m file
CrashSightConfig* config = [[CrashSightConfig alloc] init];
// Customize the domain name for reporting (optional)
config.crashServerUrl = @"http://xxxx";
config.debugMode = true;//open debug mode
NSString* appId = @"appId";
[CrashSight startWithAppId:appId config:config];
2.1.2 Swift Initialization
- If there is no Objective-C Bridging Header in the project, create one. · Create a new .h file · Find Build Settings->Swift Compiler-General->Objective-C Bridging Header, fill in the path of the .h file you just created
- Import header file
#import <CrashSight/CrashSight.h>
in the project's Objective-C Bridging Header - Initialize in XXXApp.swift
@main
struct XXXApp: App {
init() {
let config = CrashSightConfig();
config.crashServerUrl = "http://xxxx";
config.debugMode = true;
let appId = "appId";
CrashSight.start(withAppId:appId,config:config);
}
...
Domain name for reporting
- Local(China) public cloud https://mac.crashsight.qq.com/pb/sync
- International public cloud https://mac.crashsight.wetest.net/pb/sync
2.2 Integration Result Testing
After initializing CrashSight, trigger a crash by a button. A simple trigger code, such as illegal memory access, can be written to cause a crash:
int* a = NULL;
a[10000] = 5;
- a. Enable Debug mode. Initialize CrashSight and assign suitable config parameters
- b. Network and report: Check if “begin to upload < CSAnalyticsLogic” or “cmd: 641” is printed in the test device log
- c. Crash detection: Check if “Handle the crash scene in callback” is printed in the test device log
- d. Report exceptions: Check if “begin to upload < CSCrashLogic” or “cmd: 631” is printed in the test device log
3 Mac Interfaces
3.1 Initialize CrashSight with Specified Configurations
Class:CrashSight
Method:+ (void)startWithAppId:(NSString * CS_NULLABLE)appId
developmentDevice:(BOOL)development
config:(CrashSightConfig * CS_NULLABLE)config;
Parameter | Type | Note |
---|---|---|
appid | NSString * | The appid obtained from the CrashSight backend |
development | BOOL | Whether it is a development device |
config | CrashSightConfig * | See CrashSightConfig.h header file for details |
3.2 Set User ID
Class:CrashSight
Method:+ (void)setUserIdentifier:(NSString *)userId;
Parameter | Type | Note |
---|---|---|
userId | NSString * | User ID |
3.3 Set App Version Info
Class:CrashSight
Method:+ (void)updateAppVersion:(NSString *)version;
Parameter | Type | Note |
---|---|---|
version | NSString * | App Version |