This document describes how to validate the Crash Analysis feature of the Alibaba Cloud App Monitor SDK for iOS.
1. Report a crash
Write test code to simulate or trigger an app crash. For example:
ImportantDo not run the app in the Xcode debugger. The SDK does not catch crashes in the Xcode debugger.
NSMutableArray *array = @[]; [array addObject:nil]; // crashlet someNilString: String? = nil let forcedValue: String = someNilString! print("Value: \(forcedValue)")After the crash is triggered, wait about 2 minutes and view the data on the Crash page in the console.
NoteCrash data appears in the console about 2 to 3 minutes after it is collected.
In some scenarios, crash data is uploaded after the application restarts.

2. Set custom dimensions
Write test code to call the SDK and set custom dimensions. For example:
#import "AlicloudApmCore/AlicloudApmCore.h" [[EAPMApm defaultApm] setCustomValue:@"value" forKey:@"key"]; [[EAPMApm defaultApm] setCustomKeysAndValues:@{ @"key1":@"value1", @"key2":@"value2", }];#import "AlicloudApmCore/AlicloudApmCore.h" let apm = EAPMApm.defaultApm() apm.setCustomValue("value", forKey: "key") apm.setCustomKeysAndValues([ "key1": "value1", "key2": "value2" ])About 2 minutes after you trigger a crash, you can view the report on the Crash page in the console, as shown in the red box in the following image.
3. Report a custom exception
Write test code to call the SDK and report a custom exception. For example:
#import "AlicloudApmCrashAnalysis/AlicloudApmCrashAnalysis.h" NSError *error = [NSError errorWithDomain:@"customError" code:10001 userInfo:@{@"errorInfoKey":@"errorInfoValue"}]; [[EAPMCrashAnalysis crashAnalysis] recordError:error userInfo:@{ @"key1":@"value1", @"key2":@"value2", }];#import "AlicloudApmCrashAnalysis/AlicloudApmCrashAnalysis.h" let crashAnalysis = CrashAnalysis.crashAnalysis() let error = NSError( domain: "customError", code: 10001, userInfo: [ "errorInfoKey": "errorInfoValue", ] ) crashAnalysis.record(error: error, userInfo: [ "key1": "value1", "key2": "value2" ])After the application restarts, you can view the data on the Custom Exception page in the console.
