Skip to content

Commit

Permalink
Gradle plugin fixes
Browse files Browse the repository at this point in the history
kpgalligan committed Jun 6, 2024
1 parent fca32de commit c17b1ea
Showing 6 changed files with 53 additions and 31 deletions.
4 changes: 1 addition & 3 deletions bugsnag-ios-link/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -41,9 +41,7 @@ gradlePlugin {

dependencies {
implementation(gradleApi())
implementation(kotlin("gradle-plugin"))
implementation(kotlin("compiler-embeddable"))

compileOnly(kotlin("gradle-plugin"))
testImplementation(kotlin("test"))
}

Original file line number Diff line number Diff line change
@@ -13,27 +13,40 @@

package co.touchlab.crashkios

import org.gradle.api.*
import org.gradle.kotlin.dsl.*
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.getByType
import org.jetbrains.kotlin.gradle.dsl.KotlinArtifactsExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinNativeFrameworkConfig
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
import java.io.*
import java.util.*
import org.jetbrains.kotlin.gradle.targets.native.tasks.artifact.kotlinArtifactsExtension

internal val Project.kotlinExtension: KotlinMultiplatformExtension get() = extensions.getByType()

@Suppress("unused")
class BugsnagLinkPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = with(project) {
val linkerArgs = "-U _OBJC_CLASS_\$_BugsnagHandledState " +
"-U _OBJC_CLASS_\$_Bugsnag " +
"-U _OBJC_CLASS_\$_BugsnagStackframe " +
"-U _OBJC_CLASS_\$_FIRStackFrame " +
"-U _OBJC_CLASS_\$_BugsnagFeatureFlag " +
"-U _OBJC_CLASS_\$_BugsnagError"
afterEvaluate {
project.kotlinExtension.crashLinkerConfig(
"-U _OBJC_CLASS_\$_BugsnagHandledState " +
"-U _OBJC_CLASS_\$_Bugsnag " +
"-U _OBJC_CLASS_\$_BugsnagStackframe " +
"-U _OBJC_CLASS_\$_FIRStackFrame " +
"-U _OBJC_CLASS_\$_BugsnagFeatureFlag " +
"-U _OBJC_CLASS_\$_BugsnagError"
)
project.kotlinExtension.crashLinkerConfig(linkerArgs)
project.kotlinArtifactsExtension.crashLinkerConfigArtifacts(linkerArgs)
}
}
}

private fun KotlinArtifactsExtension.crashLinkerConfigArtifacts(linkerOpts: String) {
artifactConfigs.withType(KotlinNativeFrameworkConfig::class.java).configureEach {
if (!isStatic) {
toolOptions {
freeCompilerArgs.add("-linker-options")
freeCompilerArgs.add(linkerOpts)
}
}
}
}
4 changes: 1 addition & 3 deletions crashlytics-ios-link/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -40,9 +40,7 @@ gradlePlugin {

dependencies {
implementation(gradleApi())
implementation(kotlin("gradle-plugin"))
implementation(kotlin("compiler-embeddable"))

compileOnly(kotlin("gradle-plugin"))
testImplementation(kotlin("test"))
}

Original file line number Diff line number Diff line change
@@ -13,25 +13,38 @@

package co.touchlab.crashkios

import org.gradle.api.*
import org.gradle.kotlin.dsl.*
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.getByType
import org.jetbrains.kotlin.gradle.dsl.KotlinArtifactsExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinNativeFrameworkConfig
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
import java.io.*
import java.util.*
import org.jetbrains.kotlin.gradle.targets.native.tasks.artifact.kotlinArtifactsExtension

internal val Project.kotlinExtension: KotlinMultiplatformExtension get() = extensions.getByType()

@Suppress("unused")
class CrashlyticsLinkPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = with(project) {
val linkerArgs = "-U _FIRCLSExceptionRecordNSException " +
"-U _OBJC_CLASS_\$_FIRStackFrame " +
"-U _OBJC_CLASS_\$_FIRExceptionModel " +
"-U _OBJC_CLASS_\$_FIRCrashlytics"
afterEvaluate {
project.kotlinExtension.crashLinkerConfig(
"-U _FIRCLSExceptionRecordNSException " +
"-U _OBJC_CLASS_\$_FIRStackFrame " +
"-U _OBJC_CLASS_\$_FIRExceptionModel " +
"-U _OBJC_CLASS_\$_FIRCrashlytics"
)
project.kotlinExtension.crashLinkerConfig(linkerArgs)
project.kotlinArtifactsExtension.crashLinkerConfigArtifacts(linkerArgs)
}
}
}

private fun KotlinArtifactsExtension.crashLinkerConfigArtifacts(linkerOpts: String) {
artifactConfigs.withType(KotlinNativeFrameworkConfig::class.java).configureEach {
if (!isStatic) {
toolOptions {
freeCompilerArgs.add("-linker-options")
freeCompilerArgs.add(linkerOpts)
}
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ kotlin.code.style=official
SONATYPE_HOST=DEFAULT
RELEASE_SIGNING_ENABLED=true
GROUP=co.touchlab.crashkios
VERSION_NAME=0.8.6
VERSION_NAME=0.8.7

POM_URL=https://github.com/touchlab/CrashKios
POM_DESCRIPTION=Kotlin Native iOS Crash Report Library
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -5,15 +5,15 @@ targetSdk = "34"
compileSdk = "34"

# Dependencies
kotlin = "1.9.22"
kotlin = "1.9.24"
android-gradle-plugin = "8.2.1"
mavenPublish = "0.26.0"
touchlab-docusaurus-template = "0.1.10"
gradlePublish = "1.2.1"
nsexceptionKt = "0.1.10"
firebase-crashlytics = "18.4.1"
bugsnag = "5.31.1"
crashkios = "0.9.0"
crashkios = "0.8.7"

# Sample Apps
androidx-core = "1.12.0"

0 comments on commit c17b1ea

Please sign in to comment.