PlcrashReporter هي مكتبة مفتوحة المصدر موثوقة توفر إطارًا للإبلاغ عن تصادم الحية للعملية للاستخدام على iOS و MacOS و TVOs. تكتشف المكتبة تعطل وإنشاء تقارير للمساعدة في التحقيق واستكشاف الأخطاء وإصلاحها مع معلومات التطبيق والنظام والعملية والخيط ، وما إلى ذلك ، وكذلك آثار المكدس.
أسهل طريقة لاستخدام PlcrashReporter هي باستخدام AppCenter. ومع ذلك ، إذا كنت ترغب في استخدام PlcrashReporter مباشرة ، فاحصل على أحدث إصدار في صفحة الإصدارات.
يتم إخراج تقارير التصادم كرسائل مشفرة للبروتوبوف ، وقد يتم فك تشفيرها باستخدام مكتبة CrashReporter أو أي ترميز مخازن بروتوكول Google.
بالإضافة إلى دعم فك تشفير المكتبات ، يمكنك استخدام plcrashutil Binary لتحويل تقارير التصادم إلى تنسيق نص iPhone القياسي من Apple:
plcrashutil convert -- format = iphone example_report . plcrash يمكنك استخدام أداة سطر أوامر atos لترميز الإخراج. لمزيد من المعلومات حول هذه الأداة ، راجع إضافة أسماء الرموز المحددة إلى تقرير تحطم. قد تتضمن إصدارات المكتبة المستقبلية تنسيقات مدمجة قابلة لإعادة الاستخدام ، لإخراج التنسيقات البديلة مباشرة من الهاتف.
يمكن إضافة PlcrashReporter إلى تطبيقك عبر Cocoapods أو Carthage أو Swift Package Manager ، أو عن طريق إضافة الثنائيات يدويًا إلى مشروعك.
Podfile الخاص بك: pod 'PLCrashReporter'pod install لتثبيت POD المحددة حديثًا وافتح .xcworkspace للمشروع.Cartfile الخاص بك: github "microsoft/plcrashreporter"carthage update --use-xcframeworks لجلب التبعيات.Frameworks, Libraries and Embedded Content . لنظام التشغيل iOS و TVOs ، قم Embed Do not embed . لماكوسات ، قم Embed Embed and Sign .ملاحظة: لا يقوم تكامل قرطاج ببناء التبعية بشكل صحيح في XCode 12 مع العلم "-لا استخدامات الاستخدام" أو من فرع معين. لجعلها تعمل ، راجع هذه التعليمات.
ملاحظة: يحتوي PlcrashReporter Xcframework على ثنائيات ثابتة لنظام التشغيل iOS و TVOs ، وثنائيات ديناميكية لـ MacOS. عند إضافة الإطار إلى مشروعك ، تأكد من أنه في
Frameworks, Libraries and Embedded Contentيتم تحديدEmbedDo not embedلنظام التشغيل iOS و TVOsEmbed and SignMacOS.PLCrashReporter-Static-{version}.zipهو استثناء-أنه يحتوي على أطر ثابتة لجميع الأنظمة الأساسية.
يوضح المثال التالي طريقة كيفية تهيئة مراسل التصادم. يرجى ملاحظة أن تمكين التقارير في التصادم في العملية سوف يتعارض مع أي تصحيحات مرفقة ، لذا تأكد من عدم إرفاق الأخطاء عند تعطل التطبيق.
@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);
}
// }يمكن إجراء التحقق من تقرير التصادم الذي تم جمعه بالطريقة التالية:
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 ];
}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 (!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 ) " )
}
// }يمكن إجراء التحقق من تقرير التصادم الذي تم جمعه بالطريقة التالية:
// 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 ( ) أيضًا ، يتم استخدام الأدوات الاختيارية التالية لبناء موارد إضافية:
protobuf-c لتحويل ملفات بروتوكول .proto راجع مستودع Protobuf-C الرسمي لمزيد من المعلومات أو استخدم Homebrew لتثبيته.افتح نافذة جديدة للمحطة الخاصة بك.
انتقل إلى المجلد الجذر لـ PlcrashReporter وركض
xcodebuild -configuration Release -target ' CrashReporter 'لإنشاء الثنائيات لجميع المنصات.
لتحديث تبعية protobuf-c :
protobuf-ch و protobuf-cc من مستودع Protobuf-C github.Dependencies/protobuf-c بالمواد التي تم تنزيلها../Dependencies/protobuf-c/generate-pb-c.shنحن نتطلع إلى مساهماتك عبر طلبات السحب.
للمساهمة في PlcrashReporter ، تحتاج إلى الأدوات المذكورة أعلاه لبناء plcrashreporter لجميع البنية و protobuf-c لتحويل ملفات بروتوكول .proto
اعتمد هذا المشروع رمز سلوك المصدر المفتوح Microsoft. لمزيد من المعلومات ، راجع مدونة الشهادة الأسئلة الشائعة أو الاتصال بـ [email protected] مع أي أسئلة أو تعليقات إضافية.