Skip to content

Commit 3a764f8

Browse files
authored
Merge pull request #44 from backtrace-labs/develop
Allow PLCrashReporter customization (#43)
2 parents 19e90ac + 1be3668 commit 3a764f8

20 files changed

+128
-75
lines changed

Backtrace.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Pod::Spec.new do |s|
1010

1111
s.name = "Backtrace"
12-
s.version = "1.5.5"
12+
s.version = "1.5.6"
1313
s.summary = "Backtrace's integration with iOS, macOS and tvOS"
1414
s.description = "Reliable crash and hang reporting for iOS, macOS and tvOS."
1515
s.homepage = "https://backtrace.io/"

Backtrace.xcodeproj/project.pbxproj

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373
A8BE9BEC461DB224950FF9F2 /* Pods_Example_tvOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F9E84E683CE60F74196C77AC /* Pods_Example_tvOS.framework */; };
7474
DC873DB19BD91A1268112804 /* Pods_Backtrace_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F832896FDD11162B84E86E23 /* Pods_Backtrace_iOS.framework */; };
7575
DE46BAA3E4497194057A99FE /* Pods_Example_iOS_ObjC.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A51056C8548E16A5E320976D /* Pods_Example_iOS_ObjC.framework */; };
76-
F21211A5222348AC000B3692 /* CrashReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F21211A4222348AC000B3692 /* CrashReporter.swift */; };
77-
F21211A6222348AC000B3692 /* CrashReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F21211A4222348AC000B3692 /* CrashReporter.swift */; };
76+
F21211A5222348AC000B3692 /* BacktraceCrashReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F21211A4222348AC000B3692 /* BacktraceCrashReporter.swift */; };
77+
F21211A6222348AC000B3692 /* BacktraceCrashReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F21211A4222348AC000B3692 /* BacktraceCrashReporter.swift */; };
7878
F21211A8222348C2000B3692 /* SignalContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = F21211A7222348C2000B3692 /* SignalContext.swift */; };
7979
F21211A9222348C2000B3692 /* SignalContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = F21211A7222348C2000B3692 /* SignalContext.swift */; };
8080
F21771BE21E341CA0059896E /* Dispatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2CC8ACA21CF8D8400A68CAC /* Dispatcher.swift */; };
@@ -156,7 +156,7 @@
156156
F2981BC922901B1400DFE098 /* AttributesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2981BC822901B1400DFE098 /* AttributesTests.swift */; };
157157
F2981BCA22901B1400DFE098 /* AttributesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2981BC822901B1400DFE098 /* AttributesTests.swift */; };
158158
F2981BCB22901B1400DFE098 /* AttributesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2981BC822901B1400DFE098 /* AttributesTests.swift */; };
159-
F29959AB225539960085B5C3 /* CrashReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F21211A4222348AC000B3692 /* CrashReporter.swift */; };
159+
F29959AB225539960085B5C3 /* BacktraceCrashReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F21211A4222348AC000B3692 /* BacktraceCrashReporter.swift */; };
160160
F29959AC2255399B0085B5C3 /* BacktraceReport.swift in Sources */ = {isa = PBXBuildFile; fileRef = F282075721CEA31F0017367F /* BacktraceReport.swift */; };
161161
F29959AD22553B340085B5C3 /* Model.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = F2AB639A22479A3200939BC9 /* Model.xcdatamodeld */; };
162162
F29CD78A21FC5F8500216C59 /* BacktraceDatabaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F29CD78721FC5F6500216C59 /* BacktraceDatabaseTests.swift */; };
@@ -345,7 +345,7 @@
345345
D8121A05EF59A842F7A61513 /* Pods_Backtrace_macOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Backtrace_macOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
346346
D94F6D9E40D8D8F0A249C779 /* Pods-Backtrace-iOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Backtrace-iOSTests.release.xcconfig"; path = "Target Support Files/Pods-Backtrace-iOSTests/Pods-Backtrace-iOSTests.release.xcconfig"; sourceTree = "<group>"; };
347347
DB14DBA09154EA687EDB4861 /* Pods-Example-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example-iOS.release.xcconfig"; path = "Target Support Files/Pods-Example-iOS/Pods-Example-iOS.release.xcconfig"; sourceTree = "<group>"; };
348-
F21211A4222348AC000B3692 /* CrashReporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrashReporter.swift; sourceTree = "<group>"; };
348+
F21211A4222348AC000B3692 /* BacktraceCrashReporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BacktraceCrashReporter.swift; sourceTree = "<group>"; };
349349
F21211A7222348C2000B3692 /* SignalContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignalContext.swift; sourceTree = "<group>"; };
350350
F21D302A224A18D50013B5D7 /* Store.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Store.swift; sourceTree = "<group>"; };
351351
F21DD3B02255EA2A00404CC3 /* test.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test.txt; sourceTree = "<group>"; };
@@ -696,14 +696,6 @@
696696
path = Network;
697697
sourceTree = "<group>";
698698
};
699-
F282076521CEAC230017367F /* Crash Reporting */ = {
700-
isa = PBXGroup;
701-
children = (
702-
F21211A4222348AC000B3692 /* CrashReporter.swift */,
703-
);
704-
path = "Crash Reporting";
705-
sourceTree = "<group>";
706-
};
707699
F28F164121E28421008E4B96 /* Client */ = {
708700
isa = PBXGroup;
709701
children = (
@@ -797,6 +789,7 @@
797789
F2D7122021F10C45002D2A26 /* BacktraceClientConfiguration.swift */,
798790
F2D7122321F10E78002D2A26 /* BacktraceCredentials.swift */,
799791
F25F9E9621EE84AF00236E04 /* BacktraceReportStatus.swift */,
792+
F21211A4222348AC000B3692 /* BacktraceCrashReporter.swift */,
800793
F2AFB5A022274F1000AAA1D7 /* Internal */,
801794
);
802795
path = Public;
@@ -810,7 +803,6 @@
810803
F2CC8AC921CF8D6C00A68CAC /* Dispatching */,
811804
F29CD78F21FCC23800216C59 /* Watcher */,
812805
F28F164121E28421008E4B96 /* Client */,
813-
F282076521CEAC230017367F /* Crash Reporting */,
814806
F282075D21CEAB930017367F /* Network */,
815807
F282075621CEA3030017367F /* Repository */,
816808
F28F164F21E28833008E4B96 /* Error */,
@@ -1762,7 +1754,7 @@
17621754
isa = PBXSourcesBuildPhase;
17631755
buildActionMask = 2147483647;
17641756
files = (
1765-
F29959AB225539960085B5C3 /* CrashReporter.swift in Sources */,
1757+
F29959AB225539960085B5C3 /* BacktraceCrashReporter.swift in Sources */,
17661758
28F95BCF22526061003936E0 /* BacktraceLogger.swift in Sources */,
17671759
28F95BD022526064003936E0 /* BacktraceClient.swift in Sources */,
17681760
28F95BCD2252605A003936E0 /* BacktraceClientDelegate.swift in Sources */,
@@ -1864,7 +1856,7 @@
18641856
2846E1FF223070CB0035F98C /* Attachment.swift in Sources */,
18651857
F2D7122521F10E78002D2A26 /* BacktraceCredentials.swift in Sources */,
18661858
F28F164721E28441008E4B96 /* BacktraceReporter.swift in Sources */,
1867-
F21211A6222348AC000B3692 /* CrashReporter.swift in Sources */,
1859+
F21211A6222348AC000B3692 /* BacktraceCrashReporter.swift in Sources */,
18681860
F282075921CEA31F0017367F /* BacktraceReport.swift in Sources */,
18691861
28AC773A21F8C29800FED661 /* PersistentRepository.swift in Sources */,
18701862
28614F9F220B900300D35EFB /* DefaultAttributes.swift in Sources */,
@@ -1945,7 +1937,7 @@
19451937
2846E1FE223070CB0035F98C /* Attachment.swift in Sources */,
19461938
F2D7122421F10E78002D2A26 /* BacktraceCredentials.swift in Sources */,
19471939
F28F164621E28441008E4B96 /* BacktraceReporter.swift in Sources */,
1948-
F21211A5222348AC000B3692 /* CrashReporter.swift in Sources */,
1940+
F21211A5222348AC000B3692 /* BacktraceCrashReporter.swift in Sources */,
19491941
F2C1514221F7D8E30014F1B3 /* PersistentRepository.swift in Sources */,
19501942
F2D8BE3821BD7894007CFEFA /* BacktraceError.swift in Sources */,
19511943
F282075821CEA31F0017367F /* BacktraceReport.swift in Sources */,

Backtrace.xcodeproj/xcshareddata/xcschemes/Example-iOS-ObjC.xcscheme

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30-
<Testables>
31-
</Testables>
3230
<MacroExpansion>
3331
<BuildableReference
3432
BuildableIdentifier = "primary"
@@ -38,13 +36,13 @@
3836
ReferencedContainer = "container:Backtrace.xcodeproj">
3937
</BuildableReference>
4038
</MacroExpansion>
41-
<AdditionalOptions>
42-
</AdditionalOptions>
39+
<Testables>
40+
</Testables>
4341
</TestAction>
4442
<LaunchAction
4543
buildConfiguration = "Debug"
46-
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
47-
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
44+
selectedDebuggerIdentifier = ""
45+
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
4846
launchStyle = "0"
4947
useCustomWorkingDirectory = "NO"
5048
ignoresPersistentStateOnLaunch = "NO"
@@ -61,8 +59,6 @@
6159
ReferencedContainer = "container:Backtrace.xcodeproj">
6260
</BuildableReference>
6361
</BuildableProductRunnable>
64-
<AdditionalOptions>
65-
</AdditionalOptions>
6662
</LaunchAction>
6763
<ProfileAction
6864
buildConfiguration = "Release"

Backtrace.xcodeproj/xcshareddata/xcschemes/Example-macOS-ObjC.xcscheme

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
</TestAction>
4242
<LaunchAction
4343
buildConfiguration = "Debug"
44-
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
45-
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
44+
selectedDebuggerIdentifier = ""
45+
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
4646
launchStyle = "0"
4747
useCustomWorkingDirectory = "NO"
4848
ignoresPersistentStateOnLaunch = "NO"

Brewfile.lock.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
"entries": {
33
"brew": {
44
"fastlane": {
5-
"version": "2.152.0",
5+
"version": "2.161.0",
66
"bottle": {
77
"cellar": ":any",
88
"prefix": "/usr/local",
99
"files": {
1010
"catalina": {
11-
"url": "https://homebrew.bintray.com/bottles/fastlane-2.152.0.catalina.bottle.tar.gz",
12-
"sha256": "133fd49959694621a60d6212e9e21631c34015b836427353e8c864a280d579cb"
11+
"url": "https://homebrew.bintray.com/bottles/fastlane-2.161.0.catalina.bottle.tar.gz",
12+
"sha256": "fa9092e388bca3b32807eddcc1c6514e92f3e5e20da966f82bd7670c3e0d42d3"
1313
},
1414
"mojave": {
15-
"url": "https://homebrew.bintray.com/bottles/fastlane-2.152.0.mojave.bottle.tar.gz",
16-
"sha256": "346c5892ebc93be7f37ab7e080db591d4d91c1849096b478739a1873988af4f9"
15+
"url": "https://homebrew.bintray.com/bottles/fastlane-2.161.0.mojave.bottle.tar.gz",
16+
"sha256": "431e169597585884f93781f00c17c64fd779d6ea311602891567236146473c5f"
1717
},
1818
"high_sierra": {
19-
"url": "https://homebrew.bintray.com/bottles/fastlane-2.152.0.high_sierra.bottle.tar.gz",
20-
"sha256": "6d96e2a20decfae69a34e7e774edaa30da4b3d7f7895291612c33031a6d27d53"
19+
"url": "https://homebrew.bintray.com/bottles/fastlane-2.161.0.high_sierra.bottle.tar.gz",
20+
"sha256": "39bdfc80e896775b45617f1b7bb9f209cad91b91a5bb0a3cbeae0ed0080f45cc"
2121
}
2222
}
2323
}
@@ -27,11 +27,11 @@
2727
"system": {
2828
"macos": {
2929
"catalina": {
30-
"HOMEBREW_VERSION": "2.4.7",
30+
"HOMEBREW_VERSION": "2.5.2",
3131
"HOMEBREW_PREFIX": "/usr/local",
32-
"Homebrew/homebrew-core": "3635145b479e8168b3a6b6f93c6662e862364fd3",
32+
"Homebrew/homebrew-core": "3cc2bc2196267adcdaa2e256cd8af6c30207c049",
3333
"CLT": "1103.0.32.62",
34-
"Xcode": "11.6",
34+
"Xcode": "11.7",
3535
"macOS": "10.15.6"
3636
}
3737
}

Podfile.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
PODS:
2-
- Backtrace (1.5.5):
2+
- Backtrace (1.5.6):
33
- Backtrace-PLCrashReporter
4-
- Backtrace-PLCrashReporter (1.5.2)
5-
- Nimble (8.0.5)
6-
- Quick (2.2.0)
4+
- Backtrace-PLCrashReporter (1.5.4)
5+
- Nimble (8.1.2)
6+
- Quick (3.0.0)
77

88
DEPENDENCIES:
99
- Backtrace (from `./Backtrace.podspec`)
@@ -22,10 +22,10 @@ EXTERNAL SOURCES:
2222
:path: "./Backtrace.podspec"
2323

2424
SPEC CHECKSUMS:
25-
Backtrace: d3dfe8106c641cbee1413dec5e3c997840bbe17d
26-
Backtrace-PLCrashReporter: cae6b9bd6d0b2f55adc114c1a41908c03f1bfc72
27-
Nimble: 4ab1aeb9b45553c75b9687196b0fa0713170a332
28-
Quick: 7fb19e13be07b5dfb3b90d4f9824c855a11af40e
25+
Backtrace: 90f5a8b6bc9d417a444ce62435bbda0c54fa8d89
26+
Backtrace-PLCrashReporter: 65b9aae5468bb6af6b55b88de22b49e031331054
27+
Nimble: 3864815b4703c7ebffba875973c70e854489fbae
28+
Quick: 6d9559f40647bc4d510103842ef2fdd882d753e2
2929

3030
PODFILE CHECKSUM: 62d8c592f7a14dbdbf06ce7cbf47810c1a25075e
3131

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
9090
1. [Initialize client](#documentation-client-initialization)
9191
2. [Configure client](#documentation-client-configuration)
9292
* [Database settings](#documentation-database-settings)
93+
* [PLCrashReporter configuration](#documentation-plcrashreporter-configuration)
9394
3. [Events handling](#documentation-events-handling)
9495
4. [Attributes](#documentation-attributes)
9596
5. [Attachments](#documentation-attachments)
@@ -227,6 +228,44 @@ BacktraceClientConfiguration *configuration = [[BacktraceClientConfiguration all
227228
BacktraceClient.shared = [[BacktraceClient alloc] initWithConfiguration: configuration error: nil];
228229
```
229230
231+
### PLCrashReporter configuration <a name="documentation-plcrashreporter-configuration"></a>
232+
`BacktraceClient` allows to customize the configuration of the `PLCrashReporter` by injecting its instance.
233+
234+
- Swift
235+
```swift
236+
let backtraceCredentials = BacktraceCredentials(endpoint: URL(string: "https://backtrace.io")!, token: "token")
237+
let backtraceConfiguration = BacktraceClientConfiguration(credentials: backtraceCredentials)
238+
BacktraceClient.shared = try? BacktraceClient(
239+
configuration: backtraceConfiguration,
240+
crashReporter: BacktraceCrashReporter(config: PLCrashReporterConfig.defaultConfiguration()))
241+
// or
242+
BacktraceClient.shared = try? BacktraceClient(
243+
configuration: backtraceConfiguration,
244+
crashReporter: BacktraceCrashReporter(reporter: PLCrashReporter.shared()))
245+
```
246+
247+
- Objective-C
248+
```objective-c
249+
BacktraceCredentials *credentials = [[BacktraceCredentials alloc]
250+
initWithEndpoint: [NSURL URLWithString: @"https://backtrace.io"]
251+
token: @"token"];
252+
253+
BacktraceClientConfiguration *configuration = [[BacktraceClientConfiguration alloc]
254+
initWithCredentials: credentials];
255+
256+
BacktraceClient.shared = [[BacktraceClient alloc]
257+
initWithConfiguration: configuration
258+
crashReporter: [[BacktraceCrashReporter alloc] initWithConfig: PLCrashReporterConfig.defaultConfiguration]
259+
error: nil];
260+
261+
// or
262+
BacktraceClient.shared = [[BacktraceClient alloc]
263+
initWithConfiguration: configuration
264+
crashReporter: [[BacktraceCrashReporter alloc] initWithReporter: PLCrashReporter.sharedReporter]
265+
error: nil];
266+
```
267+
268+
230269
## Events handling <a name="documentation-events-handling"></a>
231270
`BacktraceClient` allows you to subscribe for events produced before and after sending each report. You have to only attach object which confirm to `BacktraceClientDelegate` protocol.
232271
- Swift

Sources/Features/Client/BacktraceResponse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private extension Optional where Wrapped == Data {
1919
case .none:
2020
return ""
2121
case .some(let data):
22-
return (try? JSONSerialization.jsonObject(with: data, options: [.fragmentsAllowed])) ?? ""
22+
return (try? JSONSerialization.jsonObject(with: data, options: [.allowFragments])) ?? ""
2323
}
2424
}
2525
}

0 commit comments

Comments
 (0)