Skip to content

Commit b6745ea

Browse files
committed
Merge branch 'main' into jj/crashlytics-sample
2 parents 1019f96 + 3cb49c8 commit b6745ea

File tree

68 files changed

+2521
-207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2521
-207
lines changed

.github/workflows/deploy.yml

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,77 @@
11
name: deploy
22
on: workflow_dispatch
3-
#on:
4-
# pull_request:
5-
# branches:
6-
# - main
7-
# push:
8-
# branches:
9-
# - main
103

114
jobs:
12-
build:
13-
strategy:
14-
matrix:
15-
os: [macOS-latest]
16-
runs-on: ${{matrix.os}}
5+
# find-release:
6+
# runs-on: ubuntu-latest
7+
# steps:
8+
# - name: Checkout the repo
9+
# uses: actions/checkout@v2
10+
# - name: Read version from gradle.properties
11+
# id: read_version
12+
# uses: christian-draeger/read-properties@1.0.1
13+
# with:
14+
# path: './gradle.properties'
15+
# property: 'VERSION_NAME'
16+
17+
deploy:
18+
runs-on: macOS-latest
1719
steps:
1820
- name: Checkout the repo
1921
uses: actions/checkout@v2
22+
23+
- name: Read gradle.properties
24+
id: props
25+
uses: juliangruber/read-file-action@v1
26+
with:
27+
path: ./gradle.properties
28+
29+
- uses: actions-ecosystem/action-regex-match@v2
30+
id: version-match
31+
with:
32+
text: ${{ steps.props.outputs.content }}
33+
regex: '^VERSION_NAME=(.*?)$'
34+
flags: gm
35+
36+
- name: Echo Version
37+
run: echo ${{ steps.version-match.outputs.group1 }}
38+
2039
- uses: actions/setup-java@v2
2140
with:
2241
distribution: "adopt"
2342
java-version: "11"
43+
2444
- name: Validate Gradle Wrapper
2545
uses: gradle/wrapper-validation-action@v1
46+
2647
- name: Cache gradle
2748
uses: actions/cache@v2
2849
with:
2950
path: ~/.gradle/caches
3051
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
3152
restore-keys: |
3253
${{ runner.os }}-gradle-
54+
3355
- name: Cache konan
3456
uses: actions/cache@v2
3557
with:
3658
path: ~/.konan
3759
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
3860
restore-keys: |
3961
${{ runner.os }}-gradle-
40-
- name: Publish Mac Artifacts
41-
if: matrix.os == 'macOS-latest'
42-
run: ./gradlew publish --no-daemon --stacktrace
62+
63+
- name: Publish
64+
run: ./gradlew publish --no-daemon --stacktrace --no-build-cache
4365
env:
44-
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
45-
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
46-
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
66+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
67+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
68+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
69+
70+
- name: Create Release
71+
if: ${{ contains(steps.version-match.outputs.group1, 'SNAPSHOT') == false }}
72+
uses: touchlab/release-action@v1.10.0
73+
with:
74+
tag: ${{ steps.version-match.outputs.group1 }}
75+
4776
env:
4877
GRADLE_OPTS: -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=512m"

README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ Thin library that provides symbolicated crash reports for Kotlin code on iOS. Su
44

55
To use crash reporting with general logging support, check out [Kermit](https://github.com/touchlab/Kermit/).
66

7-
> ## **We're Hiring!**
7+
> ## Subscribe!
88
>
9-
> Touchlab is looking for a Mobile Developer, with Android/Kotlin experience, who is eager to dive into Kotlin Multiplatform Mobile (KMM) development. Come join the remote-first team putting KMM in production. [More info here](https://go.touchlab.co/careers-gh).
9+
> We build solutions that get teams started smoothly with Kotlin Multiplatform Mobile and ensure their success in production. Join our community to learn how your peers are adopting KMM.
10+
[Sign up here](https://go.touchlab.co/newsletter-gh)!
1011

1112
## The Problem
1213

@@ -55,7 +56,7 @@ CrashlyticsKotlin.setCustomValue("someKey", "someValue")
5556

5657
### Testing
5758

58-
You test code should not call `enableCrashlytics()`. Before calling `enableCrashlytics()`, calls to `CrashlyticsKotlin` are all no-ops. Also, on iOS, avoiding `enableCrashlytics()` means you don't need to worry about Crashlytics linker issues.
59+
Your test code should not call `enableCrashlytics()`. Before calling `enableCrashlytics()`, calls to `CrashlyticsKotlin` are all no-ops. Also, on iOS, avoiding `enableCrashlytics()` means you don't need to worry about Crashlytics linker issues.
5960

6061
### Linking
6162

@@ -74,7 +75,13 @@ Undefined symbols for architecture x86_64:
7475
ld: symbol(s) not found for architecture x86_64
7576
```
7677

77-
To resolve this, you should tell the linker that Crashlytics will be added later. To do that, call `crashlyticsLinkerConfig()` in the `kotlin` section of your `build.gradle.kts`.
78+
To resolve this, you should tell the linker that Crashlytics will be added later. To do that, add a Gradle plugin that will configure your linker settings.
79+
80+
```kotlin
81+
plugins {
82+
id("co.touchlab.crashkios.crashlyticslink") version "x.y.z"
83+
}
84+
```
7885

7986
## Bugsnag Usage
8087

@@ -161,4 +168,20 @@ Undefined symbols for architecture x86_64:
161168
ld: symbol(s) not found for architecture x86_64
162169
```
163170

164-
To resolve this, you should tell the linker that Bugsnag will be added later. To do that, call `bugsnagLinkerConfig()` in the `kotlin` section of your `build.gradle.kts`.
171+
To resolve this, you should tell the linker that Bugsnag will be added later. To do that, add a Gradle plugin that will configure your linker settings.
172+
173+
```kotlin
174+
plugins {
175+
id("co.touchlab.crashkios.bugsnaglink") version "x.y.z"
176+
}
177+
```
178+
179+
## NSExceptionKt
180+
181+
CrashKiOS and Kermit previously created 2 reports on a crash because none of the crash reporting clients had an obvious way to do one. [Rick Clephas](https://github.com/rickclephas) has done some excellent work figuring that out with [NSExceptionKt](https://github.com/rickclephas/NSExceptionKt). CrashKiOS now uses part of that library as a base and we've merged the cinterop from Kermit and NSExeptionKt to handle crashes as well as breadcrumb values and log statements.
182+
183+
## Getting Help
184+
185+
CrashKiOS support can be found in the Kotlin Community Slack, [request access here](http://slack.kotlinlang.org/). Post in the "[#touchlab-tools](https://kotlinlang.slack.com/archives/CTJB58X7X)" channel.
186+
187+
For direct assistance, please [contact Touchlab](https://go.touchlab.co/contactus-gh) to discuss support options.

bugsnag-ios-link/build.gradle.kts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2022 Touchlab.
3+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4+
* in compliance with the License. You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software distributed under the License
9+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10+
* or implied. See the License for the specific language governing permissions and limitations under
11+
* the License.
12+
*/
13+
14+
plugins {
15+
`kotlin-dsl`
16+
kotlin("jvm")
17+
id("java-gradle-plugin")
18+
id("com.vanniktech.maven.publish.base")
19+
id("com.gradle.plugin-publish") version "1.0.0"
20+
}
21+
22+
repositories {
23+
gradlePluginPortal()
24+
mavenCentral()
25+
}
26+
27+
gradlePlugin {
28+
plugins {
29+
register("bugsnag-ios-link-plugin") {
30+
id = "co.touchlab.crashkios.bugsnaglink"
31+
implementationClass = "co.touchlab.crashkios.BugsnagLinkPlugin"
32+
displayName = "Bugsnag iOS Link Plugin"
33+
}
34+
}
35+
}
36+
37+
pluginBundle {
38+
website = "https://github.com/touchlab/CrashKiOS"
39+
vcsUrl = "https://github.com/touchlab/CrashKiOS.git"
40+
41+
description = "CrashKiOS linker params for Bugsnag on iOS"
42+
43+
tags = listOf("kmm", "kotlin", "multiplatform", "mobile", "ios")
44+
}
45+
46+
dependencies {
47+
implementation(kotlin("stdlib-jdk8"))
48+
implementation(gradleApi())
49+
implementation(kotlin("gradle-plugin"))
50+
implementation(kotlin("compiler-embeddable"))
51+
52+
testImplementation(kotlin("test"))
53+
}
54+
55+
java {
56+
sourceCompatibility = JavaVersion.VERSION_1_8
57+
targetCompatibility = JavaVersion.VERSION_1_8
58+
}
59+
60+
val GROUP: String by project
61+
val VERSION_NAME: String by project
62+
63+
group = GROUP
64+
version = VERSION_NAME
65+
66+
mavenPublishing {
67+
publishToMavenCentral()
68+
val releaseSigningEnabled =
69+
project.properties["RELEASE_SIGNING_ENABLED"]?.toString()?.equals("false", ignoreCase = true) != true
70+
if (releaseSigningEnabled) signAllPublications()
71+
pomFromGradleProperties()
72+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2022 Touchlab.
3+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4+
* in compliance with the License. You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software distributed under the License
9+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10+
* or implied. See the License for the specific language governing permissions and limitations under
11+
* the License.
12+
*/
13+
14+
package co.touchlab.crashkios
15+
16+
import org.gradle.api.*
17+
import org.gradle.kotlin.dsl.*
18+
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
19+
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
20+
import java.io.*
21+
import java.util.*
22+
23+
internal val Project.kotlinExtension: KotlinMultiplatformExtension get() = extensions.getByType()
24+
25+
@Suppress("unused")
26+
class BugsnagLinkPlugin : Plugin<Project> {
27+
override fun apply(project: Project): Unit = with(project) {
28+
afterEvaluate {
29+
project.kotlinExtension.crashLinkerConfig(
30+
"-U _OBJC_CLASS_\$_Bugsnag " +
31+
"-U _OBJC_CLASS_\$_BugsnagStackframe " +
32+
"-U _OBJC_CLASS_\$_FIRStackFrame " +
33+
"-U _OBJC_CLASS_\$_BugsnagFeatureFlag " +
34+
"-U _OBJC_CLASS_\$_BugsnagError"
35+
)
36+
}
37+
}
38+
}
39+
40+
private fun KotlinMultiplatformExtension.crashLinkerConfig(linkerOpts: String) {
41+
targets.withType(org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget::class.java)
42+
.map { target ->
43+
val mainCompilation = target.compilations.getByName("main")
44+
val dynamicFrameworks =
45+
target.binaries.filterIsInstance<Framework>().filter { framework -> !framework.isStatic }
46+
47+
Pair(mainCompilation, dynamicFrameworks)
48+
}
49+
.forEach { pair ->
50+
if (!pair.second.isEmpty()) {
51+
pair.first.kotlinOptions.freeCompilerArgs += listOf("-linker-options", linkerOpts)
52+
}
53+
}
54+
}

bugsnag/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ kotlin {
6868
val androidMain by sourceSets.getting {
6969
dependencies {
7070
implementation("org.jetbrains.kotlin:kotlin-stdlib")
71-
implementation("com.bugsnag:bugsnag-android:$BUGSNAG_ANDROID_VERSION")
71+
compileOnly("com.bugsnag:bugsnag-android:$BUGSNAG_ANDROID_VERSION")
7272
}
7373
}
7474

core/src/darwinMain/kotlin/co/touchlab/crashkios/core/ThreadSafeVar.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import kotlin.native.concurrent.AtomicReference
44
import kotlin.native.concurrent.freeze
55
import kotlin.reflect.KProperty
66

7+
@OptIn(FreezingIsDeprecated::class)
78
actual class ThreadSafeVar<T> actual constructor(target: T) {
89
private val atom = AtomicReference(target)
910

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2022 Touchlab.
3+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4+
* in compliance with the License. You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software distributed under the License
9+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10+
* or implied. See the License for the specific language governing permissions and limitations under
11+
* the License.
12+
*/
13+
14+
plugins {
15+
`kotlin-dsl`
16+
kotlin("jvm")
17+
id("java-gradle-plugin")
18+
id("com.vanniktech.maven.publish.base")
19+
id("com.gradle.plugin-publish") version "1.0.0"
20+
}
21+
22+
repositories {
23+
gradlePluginPortal()
24+
mavenCentral()
25+
}
26+
27+
gradlePlugin {
28+
plugins {
29+
register("crashlytics-ios-link-plugin") {
30+
id = "co.touchlab.crashkios.crashlyticslink"
31+
implementationClass = "co.touchlab.crashkios.CrashlyticsLinkPlugin"
32+
displayName = "Crashlytics iOS Link Plugin"
33+
}
34+
}
35+
}
36+
37+
pluginBundle {
38+
website = "https://github.com/touchlab/CrashKiOS"
39+
vcsUrl = "https://github.com/touchlab/CrashKiOS.git"
40+
41+
description = "CrashKiOS linker params for Crashlytics on iOS"
42+
43+
tags = listOf("kmm", "kotlin", "multiplatform", "mobile", "ios")
44+
}
45+
46+
dependencies {
47+
implementation(kotlin("stdlib-jdk8"))
48+
implementation(gradleApi())
49+
implementation(kotlin("gradle-plugin"))
50+
implementation(kotlin("compiler-embeddable"))
51+
52+
testImplementation(kotlin("test"))
53+
}
54+
55+
java {
56+
sourceCompatibility = JavaVersion.VERSION_1_8
57+
targetCompatibility = JavaVersion.VERSION_1_8
58+
}
59+
60+
val GROUP: String by project
61+
val VERSION_NAME: String by project
62+
63+
group = GROUP
64+
version = VERSION_NAME
65+
66+
mavenPublishing {
67+
publishToMavenCentral()
68+
val releaseSigningEnabled =
69+
project.properties["RELEASE_SIGNING_ENABLED"]?.toString()?.equals("false", ignoreCase = true) != true
70+
if (releaseSigningEnabled) signAllPublications()
71+
pomFromGradleProperties()
72+
}

0 commit comments

Comments
 (0)