PlcrashRosporter는 iOS, MACOS 및 TVOS에서 사용할 수있는 과정 내 라이브 충돌보고 프레임 워크를 제공하는 신뢰할 수있는 오픈 소스 라이브러리입니다. 라이브러리는 충돌을 감지하고 응용 프로그램, 시스템, 프로세스, 스레드 등의 정보 및 스택 추적에 대한 조사 및 문제 해결에 도움이되는 보고서를 생성합니다.
PlcrashRosporter를 사용하는 가장 쉬운 방법은 AppCenter를 사용하는 것입니다. 그러나 PlcrashRosporter를 직접 사용하려면 릴리스 페이지에서 최신 릴리스를 잡으십시오.
충돌 보고서는 Protobuf-Encoded 메시지로 출력되며 CrashReporter 라이브러리 또는 Google 프로토콜 버퍼 디코더를 사용하여 디코딩 될 수 있습니다.
라이브러리 내 디코딩 지원 외에도 포함 된 plcrashutil 바이너리를 사용하여 충돌 보고서를 Apple의 표준 iPhone 텍스트 형식으로 변환 할 수 있습니다.
plcrashutil convert -- format = iphone example_report . plcrash atos 명령 줄 도구를 사용하여 출력을 상징 할 수 있습니다. 이 도구에 대한 자세한 내용은 충돌 보고서에 식별 가능한 기호 이름 추가를 참조하십시오. 향후 라이브러리 릴리스에는 전화기에서 직접 대체 형식을 출력하기위한 재시험 가능한 포맷터가 내장되어있을 수 있습니다.
Cocoapods, Carthage, Swift Package Manager를 통해 PlcrashRosporter를 앱에 추가하거나 프로젝트에 바이너리를 수동으로 추가하여 앱에 추가 할 수 있습니다.
Podfile 에 다음 줄을 추가하십시오. pod 'PLCrashReporter'.xcworkspace 를 열려면 pod install 실행하십시오.Cartfile 에 다음 줄을 추가하십시오. github "microsoft/plcrashreporter"carthage update --use-xcframeworks 실행하여 종속성을 가져 오십시오.Frameworks, Libraries and Embedded Content 섹션으로 드래그 앤 드롭 삭제 . iOS 및 TVOS의 경우 Embed Do not embed 설정하십시오. MACOS의 경우 Embed Embed and Sign 으로 설정하십시오.참고 : Carthage Integration은 Xcode 12에서 플래그 "-no-use-binaries"또는 특정 지점에서 의존성을 올바르게 구축하지 않습니다. 작동하려면이 명령어를 참조하십시오.
참고 : PlcrashRashRoperter XCFramework에는 iOS 및 TVOS 용 정적 이진과 MACOS 용 동적 이진이 포함되어 있습니다. 프로젝트에 프레임 워크를 추가 할 때
Frameworks, Libraries and Embedded Content섹션EmbediOS 및 TVOS에Do not embed선택되어 있고 MACOS에Embed and Sign해야합니다.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 프로토토 파일을 C 디스크립터 코드로 변환합니다. 자세한 내용은 공식 Protobuf-C-C Repository를 참조하거나 홈 브루를 사용하여 설치하십시오.터미널의 새 창을 엽니 다.
plcrashreporter의 루트 폴더로 이동하여 실행하십시오
xcodebuild -configuration Release -target ' CrashReporter '모든 플랫폼에 대한 바이너리를 만듭니다.
protobuf-c 의존성을 업데이트하려면 :
protobuf-ch 및 protobuf-cc 파일을 다운로드하십시오.Dependencies/protobuf-c 파일을 다운로드 한 파일로 바꾸십시오../Dependencies/protobuf-c/generate-pb-c.sh풀 요청을 통해 귀하의 기여를 기대하고 있습니다.
PlcrashRashporter에 기여하려면 모든 아키텍처에 대한 plcrashRosporter 및 protobuf-c 를 구축하기 위해 위에서 언급 한 도구가 필요합니다. 프로토콜 버퍼 .proto 파일을 C 디스크립터 코드로 변환하십시오.
이 프로젝트는 Microsoft 오픈 소스 행동 강령을 채택했습니다. 자세한 내용은 추가 질문이나 의견이 있으면 행동 강령 FAQ 또는 [email protected]에 문의하십시오.