CrashKiOS: Crash on production app
Hi Touchlab,
I tried to implement CrashKiOS for our project and was successful when the app was built for development on iOS. In the production environment, there was a crash immediately after the app started.
Here is the error I picked up from the Console.
Scene FBSceneManager/sceneID:<APPBUNDLE>-default update failed: <NSError: 0x283a1ddd0; domain: FBSceneErrorDomain; code: 1 ("operation-failed"); "Scene update failed."> {
NSUnderlyingError = <NSError: 0x283a1cba0; domain: FBWorkspaceScene; code: 1; "Client process exited.">;
}
COSMCtrl _foregroundAppActivity incoming bundle <APPBUNDLE> has nil supplied UUID, finds existing 6C105A4A-1D15-36F9-8818-5CA6E2CAA5B8
Here is my gradle.build.kts for xcode:
import xx.android.bld.dependencies.LibsCommon
import xx.android.bld.dependencies.ModulesCommon
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin(xx.android.bld.dependencies.PluginsCommon.Kotlin.multiplatform)
id(xx.android.bld.dependencies.PluginsCommon.CrashkiOS.id) version xx.android.bld.dependencies.VersionsCommon.crashkios // HERE
}
kotlin {
//select iOS target platform depending on the Xcode environment variables
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64
iOSTarget("ios") {
binaries {
framework {
baseName = "xxcommon"
export(project(ModulesCommon.domain))
export(project(ModulesCommon.repositories))
export(project(ModulesCommon.data))
export(project(ModulesCommon.appServices))
export(LibsCommon.Multiplatform.Kodein.erased)
//export(Libs.Multiplatform.Ktor.Client.Features.common)
}
}
sourceSets {
all {
languageSettings.optIn("kotlin.Experimental")
languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
languageSettings.optIn("kotlinx.coroutines.FlowPreview")
languageSettings.optIn("kotlinx.serialization.InternalSerializationApi")
//languageSettings.optIn("kotlinx.serialization.UnstableDefault")
languageSettings.enableLanguageFeature("InlineClasses")
}
val commonMain by getting {
dependencies {
implementation(LibsCommon.Kotlin.stdLibCommon)
implementation(LibsCommon.Multiplatform.Kodein.erased)
//implementation(Libs.Multiplatform.Ktor.Client.Features.common)
api(project(ModulesCommon.infrastructure))
api(project(ModulesCommon.domain))
api(project(ModulesCommon.repositories))
api(project(ModulesCommon.data))
api(project(ModulesCommon.appServices))
}
}
val iosMain by getting {
dependencies {
implementation(project(ModulesCommon.infrastructure))
implementation(LibsCommon.Multiplatform.Logging.Napier.ios)
implementation(LibsCommon.Multiplatform.SQLDelight.Driver.ios)
implementation(LibsCommon.Crashkios.lib) // HERE
}
}
}
/* sourceSets["commonMain"].dependencies {
implementation(Libs.Kotlin.stdLibCommon)
api(project(Modules.domain))
api(project(Modules.repositories))
api(project(Modules.data))
} */
}
val packForXcode by tasks.creating(Sync::class) {
val targetDir = File(buildDir, "xcode-frameworks")
/// selecting the right configuration for the iOS
/// framework depending on the environment
/// variables set by Xcode build
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val framework = kotlin.targets
.getByName<KotlinNativeTarget>("ios")
.binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
from({ framework.outputDirectory })
into(targetDir)
/// generate a helpful ./gradlew wrapper with embedded Java path
doLast {
val gradlew = File(targetDir, "gradlew")
gradlew.writeText(
"#!/bin/bash\n"
+ "export 'JAVA_HOME=${System.getProperty("java.home")}'\n"
+ "cd '${rootProject.rootDir}'\n"
+ "./gradlew \$@\n"
)
gradlew.setExecutable(true)
}
}
tasks.getByName("build").dependsOn(packForXcode)
I just have no clue where to look to solve the issue. Maybe you will be able to see the problem here. Thank you for the feedback.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 2
- Comments: 32 (13 by maintainers)
I was able to reproduce this, it’s not app thinning but deployment processing. More specifically the
stripcommand now ignores that the framework needs these symbols (seems to be introduced by the new Xcode linker). I’ve replaced static calls to Crashlytics with dynamic objc calls in a PR (https://github.com/touchlab/CrashKiOS/pull/71). This still requires one undefined symbol, but that one isn’t being stripped.Since this is a larger change, we want to do some more internal testing before releasing it. I’ll keep you posted.
In the meantime, making your KMP framework static will work around the issue.
Are there plans to fix this issue? It’s the only thing blocking my team from updating our apps to Kotlin 2.0
Thanks 😃
Thanks for your interest. We’re using Crashlytics. Currently, we have decided to leave CrashkiOS since we are not able to solve it fast. I will provide a small project once I have more time. It’s not trivial.
@dmikots not yet, sadly 😦