在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:microsoft/plcrashreporter开源软件地址:https://github.com/microsoft/plcrashreporter开源编程语言:Objective-C 35.8%开源软件介绍:PLCrashReporterPLCrashReporter is a reliable open source library that provides an in-process live crash reporting framework for use on iOS, macOS and tvOS. The library detects crashes and generates reports to help your investigation and troubleshooting with the information of application, system, process, thread, etc. as well as stack traces. The easiest way to use PLCrashReporter is by using AppCenter. However, if you want to use PLCrashReporter directly, grab the latest release at releases page. Features
Prerequisites
Decoding Crash ReportsCrash reports are output as protobuf-encoded messages, and may be decoded using the CrashReporter library or any Google Protocol Buffers decoder. In addition to the in-library decoding support, you may use the included plcrashutil convert --format=iphone example_report.plcrash You can use Adding PLCrashReporter to your projectPLCrashReporter can be added to your app via CocoaPods, Carthage, Swift Package Manager, or by manually adding the binaries to your project. Integration via Cocoapods
Integration via Swift Package Manager
Integration via Carthage
Integration by copying the binaries into your project
ExampleThe following example shows a way how to initialize crash reporter. Please note that enabling in-process crash reporting will conflict with any attached debuggers so make sure the debugger isn't attached when you crash the app. Objective-c@import CrashReporter;
...
// Uncomment and implement isDebuggerAttached to safely run this code with a debugger.
// See: https://github.com/microsoft/plcrashreporter/blob/2dd862ce049e6f43feb355308dfc710f3af54c4d/Source/Crash%20Demo/main.m#L96
// if (![self isDebuggerAttached]) {
// It is strongly recommended that local symbolication only be enabled for non-release builds.
// Use PLCrashReporterSymbolicationStrategyNone for release versions.
PLCrashReporterConfig *config = [[PLCrashReporterConfig alloc] initWithSignalHandlerType: PLCrashReporterSignalHandlerTypeMach
symbolicationStrategy: PLCrashReporterSymbolicationStrategyAll];
PLCrashReporter *crashReporter = [[PLCrashReporter alloc] initWithConfiguration: config];
// Enable the Crash Reporter.
NSError *error;
if (![crashReporter enableCrashReporterAndReturnError: &error]) {
NSLog(@"Warning: Could not enable crash reporter: %@", error);
}
// } Checking collected crash report can be done in the following way: if ([crashReporter hasPendingCrashReport]) {
NSError *error;
// Try loading the crash report.
NSData *data = [crashReporter loadPendingCrashReportDataAndReturnError: &error];
if (data == nil) {
NSLog(@"Failed to load crash report data: %@", error);
return;
}
// Retrieving crash reporter data.
PLCrashReport *report = [[PLCrashReport alloc] initWithData: data error: &error];
if (report == nil) {
NSLog(@"Failed to parse crash report: %@", error);
return;
}
// We could send the report from here, but we'll just print out some debugging info instead.
NSString *text = [PLCrashReportTextFormatter stringValueForCrashReport: report withTextFormat: PLCrashReportTextFormatiOS];
NSLog(@"%@", text);
// Purge the report.
[crashReporter purgePendingCrashReport];
} Swiftimport CrashReporter
...
// Uncomment and implement isDebuggerAttached to safely run this code with a debugger.
// See: https://github.com/microsoft/plcrashreporter/blob/2dd862ce049e6f43feb355308dfc710f3af54c4d/Source/Crash%20Demo/main.m#L96
// if (!isDebuggerAttached()) {
// It is strongly recommended that local symbolication only be enabled for non-release builds.
// Use [] for release versions.
let config = PLCrashReporterConfig(signalHandlerType: .mach, symbolicationStrategy: .all)
guard let crashReporter = PLCrashReporter(configuration: config) else {
print("Could not create an instance of PLCrashReporter")
return
}
// Enable the Crash Reporter.
do {
try crashReporter.enableAndReturnError()
} catch let error {
print("Warning: Could not enable crash reporter: \(error)")
}
// } Checking collected crash report can be done in the following way: // Try loading the crash report.
if crashReporter.hasPendingCrashReport() {
do {
let data = try crashReporter.loadPendingCrashReportDataAndReturnError()
// Retrieving crash reporter data.
let report = try PLCrashReport(data: data)
// We could send the report from here, but we'll just print out some debugging info instead.
if let text = PLCrashReportTextFormatter.stringValue(for: report, with: PLCrashReportTextFormatiOS) {
print(text)
} else {
print("CrashReporter: can't convert report to text")
}
} catch let error {
print("CrashReporter failed to load and parse with error: \(error)")
}
}
// Purge the report.
crashReporter.purgePendingCrashReport() BuildingPrerequisites
Also, next optional tools are used to build additional resources:
Building
ContributingWe are looking forward to your contributions via pull requests. To contribute to PLCrashReporter, you need the tools mentioned above to build PLCrashReporter for all architectures and Code of ConductThis project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论