Skip to content

Commit 90801f0

Browse files
authored
Support Bugsnag 6.26.2 and above (#57)
1 parent 2ae23cb commit 90801f0

File tree

9 files changed

+48
-6
lines changed

9 files changed

+48
-6
lines changed

bugsnag-ios-link/src/main/kotlin/co/touchlab/crashkios/BugsnagLinkPlugin.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class BugsnagLinkPlugin : Plugin<Project> {
2727
override fun apply(project: Project): Unit = with(project) {
2828
afterEvaluate {
2929
project.kotlinExtension.crashLinkerConfig(
30-
"-U _OBJC_CLASS_\$_Bugsnag " +
30+
"-U _OBJC_CLASS_\$_BugsnagHandledState " +
31+
"-U _OBJC_CLASS_\$_Bugsnag " +
3132
"-U _OBJC_CLASS_\$_BugsnagStackframe " +
3233
"-U _OBJC_CLASS_\$_FIRStackFrame " +
3334
"-U _OBJC_CLASS_\$_BugsnagFeatureFlag " +

bugsnag/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ kotlin {
8282

8383
mainCompilation.cinterops.create("bugsnag") {
8484
includeDirs("$projectDir/src/include")
85+
includeDirs("$projectDir/src/include/private")
8586
compilerOpts("-DNS_FORMAT_ARGUMENT(A)=", "-D_Nullable_result=_Nullable")
8687
// extraOpts("-mode", "sourcecode")
8788
}

bugsnag/src/darwinMain/kotlin/co/touchlab/crashkios/bugsnag/BugsnagConfig.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public fun startBugsnag(config: BugsnagConfiguration){
1616
* Configures Bugsnag to ignore the Kotlin termination crash.
1717
*/
1818
public fun configureBugsnag(config: BugsnagConfiguration) {
19+
NSExceptionKt_OverrideBugsnagHandledStateOriginalUnhandledValue()
1920
NSExceptionKt_BugsnagConfigAddOnSendErrorBlock(config) { event ->
2021
if (event == null) return@NSExceptionKt_BugsnagConfigAddOnSendErrorBlock true
2122
!event.unhandled || event.featureFlags.none { (it as BugsnagFeatureFlag).name == kotlinCrashedFeatureFlag }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#import <objc/runtime.h>
2+
#import <Private/BugsnagHandledState.h>
3+
4+
BOOL NSExceptionKt_BugsnagHandledStateOriginalUnhandledValue(BugsnagHandledState* self, SEL _cmd) {
5+
return self.unhandled;
6+
}
7+
8+
// In Bugsnag 6.26.2 and above we need to override the originalUnhandledValue property.
9+
// By default it will prevent our exceptions from being stored to disk.
10+
// https://github.com/bugsnag/bugsnag-cocoa/pull/1549
11+
void NSExceptionKt_OverrideBugsnagHandledStateOriginalUnhandledValue() {
12+
Method method = class_getInstanceMethod([BugsnagHandledState class], @selector(originalUnhandledValue));
13+
method_setImplementation(method, (IMP)NSExceptionKt_BugsnagHandledStateOriginalUnhandledValue);
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// The following are snippets from the Bugsnag Cocoa SDK used to generate Kotlin stubs.
2+
//
3+
// https://github.com/bugsnag/bugsnag-cocoa/blob/6bcd46f5f8dc06ac26537875d501f02b27d219a9/Bugsnag/Payload/BugsnagHandledState.h
4+
//
5+
// Copyright (c) 2012 Bugsnag, https://bugsnag.com/
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining
8+
// a copy of this software and associated documentation files (the "Software"),
9+
// to deal in the Software without restriction, including without limitation
10+
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
11+
// and/or sell copies of the Software, and to permit persons to whom the Software
12+
// is furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@interface BugsnagHandledState : NSObject
20+
21+
@property(nonatomic) BOOL unhandled;
22+
23+
@end
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
package = co.touchlab.crashkios.bugsnag
22
language = Objective-C
3-
headers = Bugsnag.h BugsnagConfiguration.h BugsnagConfiguration+NSExceptionKt.h BugsnagError.h BugsnagEvent.h BugsnagFeatureFlag.h BugsnagFeatureFlagStore.h BugsnagStackframe.h
3+
headers = Bugsnag.h BugsnagConfiguration.h BugsnagConfiguration+NSExceptionKt.h BugsnagError.h BugsnagEvent.h \
4+
BugsnagFeatureFlag.h BugsnagFeatureFlagStore.h BugsnagStackframe.h Private/BugsnagHandledState.h \
5+
Private/BugsnagHandledState+NSExceptionKt.h
46

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ gradlePublish = "1.2.1"
1313
nsexceptionKt = "0.1.10"
1414
firebase-crashlytics = "18.4.1"
1515
bugsnag = "5.31.1"
16-
crashkios = "0.8.2"
16+
crashkios = "0.8.3"
1717

1818
# Sample Apps
1919
androidx-core = "1.12.0"

samples/sample-bugsnag/CrashKiOSSampleIOS/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- Bugsnag (6.22.3)
2+
- Bugsnag (6.27.2)
33
- shared (0.0.1)
44

55
DEPENDENCIES:
@@ -15,7 +15,7 @@ EXTERNAL SOURCES:
1515
:path: "../shared"
1616

1717
SPEC CHECKSUMS:
18-
Bugsnag: 17fe7e9fcf60c1877a6a638a77327dce99590991
18+
Bugsnag: d7b2e5e78eaf66246d635240c61a6c8a18e3922c
1919
shared: db2bfa2f9309d3a03ed92c95da4d0b121dfc7d02
2020

2121
PODFILE CHECKSUM: 334109894bf80203c54092dcc680f36bc85b527c

samples/sample-bugsnag/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
android:theme="@style/Theme.Samplecrashlogging">
2222
<meta-data
2323
android:name="com.bugsnag.android.API_KEY"
24-
android:value="[your key here!]"/>
24+
android:value="e3c4f60ce6e97f5dcbafabf59cbd8f29"/>
2525
<activity
2626
android:name="co.touchlab.crashkiossamplecrashlog.MainActivity"
2727
android:exported="true">

0 commit comments

Comments
 (0)