From 6b8c216610f9f6108a34b2064f1b12c534c1d7b5 Mon Sep 17 00:00:00 2001 From: aleksandr-dorofeev <84711164+aleksandr-dorofeev@users.noreply.github.com> Date: Tue, 28 Sep 2021 14:57:46 +0300 Subject: [PATCH 1/2] Specified minimum cocoapods version in podspec to 1.10.0 (#208) * Specified minimum cocoapods version in podspec to 1.10.0 --- CHANGELOG.md | 8 ++++++++ PLCrashReporter.podspec | 1 + 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c32829c..3615b09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # PLCrashReporter Change Log +## Version 1.10.1(Under development) + +* **[Improvement]** Specified minimum cocoapods version in podspec to 1.10.0 + +___ + ## Version 1.10.0 * **[Fix]** Fix error `Undefined symbols for architecture arm64` while building PLCrashReporter for simulator on Xcode 12.4 and higher. @@ -7,6 +13,8 @@ * **[Feature]** Distribute XCFramework via Cocoapods and Carthage. The XCFramework will contain static libs only. * **[Fix]** Include plcrashutil in all release archives +___ + ## Version 1.9.0 * **[Fix]** Fix `double-quoted` warnings in Xcode 12. diff --git a/PLCrashReporter.podspec b/PLCrashReporter.podspec index 0338637..6914752 100644 --- a/PLCrashReporter.podspec +++ b/PLCrashReporter.podspec @@ -1,4 +1,5 @@ Pod::Spec.new do |spec| + spec.cocoapods_version = '>= 1.10' spec.name = 'PLCrashReporter' spec.version = '1.10.0' spec.summary = 'Reliable, open-source crash reporting for iOS, macOS and tvOS.' From 11dac2fa4c72a08ce64c9ddaa914d465924f94b2 Mon Sep 17 00:00:00 2001 From: dorofeevs Date: Mon, 11 Oct 2021 15:25:00 +0300 Subject: [PATCH 2/2] Add getting started on Swift --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/README.md b/README.md index 270ed57..08f7186 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,8 @@ PLCrashReporter can be added to your app via [CocoaPods](https://guides.cocoapod The following example shows a way how to initialize crash reporter. Please note that enabling in-process crash reporting will conflict with any attached debuggers. +### Objective-c + ```objc @import CrashReporter; @@ -124,6 +126,55 @@ if ([crashReporter hasPendingCrashReport]) { } ``` +### Swift + +```swift +import CrashReporter + +... + + // 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: + +```swift + // 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() +``` + ## Building ### Prerequisites