Closed magnumrocha closed 2 years ago
Do you have a sample with 1.2.1-alpha
working?
On the error, that's a linker error. https://github.com/touchlab/CrashKiOS#linking. In theory, you have the same issue with 1.2.1-alpha
. It means you're either using a dynamic framework, or reference Crashlytics in your test code.
Assuming a dynamic framework, add:
plugins {
id("co.touchlab.crashkios.crashlyticslink") version "0.8.1"
}
Yes, I am using it on this Repository: https://github.com/Mindera/MinderaPeople-Android
It's a KMM project, and the file defines the version of libraries used: https://github.com/Mindera/MinderaPeople-Android/blob/main/buildSrc/src/main/kotlin/Versions.kt
Where I have:
const val kermitVersion = "1.2.1-alpha"
The project builds fine.
How do you build it? It's using some kind of SPM plugin
To build the KMM module: ./gradlew core:build
The SPM plugin is a gradle plugin: https://github.com/ge-org/multiplatform-swiftpackage
I ran ./gradlew createXCFramework
with Kermit 1.2.2 and it builds the whole thing. I'll try core:build
now.
I'm aware of that plugin, but "build" means a lot of things, and that plugin is very non-standard.
ok, but the failing task is not related with the plugin:
> Task :core:linkDebugFrameworkIosArm64 FAILED
This is a common Task from the KMM engine.
Unrelated thought. Unless you're stripping log statements during compile, the Kermit Gradle plugin doesn't do much. This is the first code base I've ever seen using, TBH: https://github.com/Mindera/MinderaPeople-Android/blob/beff1e44deb2a1ada02cc60bd52e05089a31ea88/buildSrc/src/main/kotlin/Plugins.kt#L26
Yes, that is. The plugin is 2 years old. Just sayin.
The Kermit plugin is being applied on: https://github.com/Mindera/MinderaPeople-Android/blob/main/core/build.gradle.kts
I get the following, which is a Kotlin 1.7.20 vs 1.7.10 issue:
> Task :core:linkDebugFrameworkIosArm64 FAILED
e: Module "co.touchlab.crashkios:core (co.touchlab.crashkios:core-iosarm64)" has a reference to symbol kotlin.native/FreezingIsDeprecated|null[0]. Neither the module itself nor its dependencies contain such declaration.
This could happen if the required dependency is missing in the project. Or if there is a dependency of "co.touchlab.crashkios:core (co.touchlab.crashkios:core-iosarm64)" that has a different version in the project than the version that "co.touchlab.crashkios:core (co.touchlab.crashkios:core-iosarm64): 0.8.1" was initially compiled with. Please check that the project configuration is correct and has consistent versions of all required dependencies.
The list of "co.touchlab.crashkios:core (co.touchlab.crashkios:core-iosarm64): 0.8.1" dependencies that may lead to conflicts:
1. "stdlib: 1.7.10" (was initially compiled with "stdlib: 1.7.20")
We might will need to specify that the new releases are only for Kotlin 1.7.20, or publish a different version that doesn't include FreezingIsDeprecated
. That's an oversight on our part, although I assumed that wouldn't make it though.
I can't see how you'd get the error you're talking about unless you also built with Kotlin 1.7.20.
The Kermit plugin is being applied on: https://github.com/Mindera/MinderaPeople-Android/blob/main/core/build.gradle.kts
I know where it's applied. I'm saying it won't do anything unless you configure it to strip log statements.
I know, when I did the test I changed the project Kotlin version to 1.7.20. But, I did not commit the change because the compilation failed with Kermit on 1.2.2 (with Kotlin on 1.7.20).
I would imagine you'll have other major issues because coroutines -native-mt doesn't support the new memory model, but we can get back to that.
Now I'm really confused. core:build
fails, but createXCFramework
works, with Kotlin 1.7.10. I never see the error you're talking about, although I'd guess it's because you commented the log writer out here: https://github.com/Mindera/MinderaPeople-Android/blob/beff1e44deb2a1ada02cc60bd52e05089a31ea88/core/src/iosMain/kotlin/com/mindera/people/wrappers/MinderaPeopleAppKt.kt#L43
val baseLogger = Logger(
config = LoggerConfig.default.copy(
logWriterList = listOf(CommonWriter() /*, CrashlyticsLogWriter()*/)
),
tag = "MinderaPeople"
)/*.also { setCrashlyticsUnhandledExceptionHook() }*/
As another side note, you'll maybe want setCrashlyticsUnhandledExceptionHook()
earlier. Koin is "lazy", so if your app crashes during init you won't see it, but that's relatively minor.
on Versions.kt:
const val kotlinVersion = "1.7.20"
...
const val kspVersion = "1.7.20-1.0.8"
...
const val kermitVersion = "1.2.2"
on buildSrc/build.gradle.kt: implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20")
RESULT:
> Task :core:linkDebugFrameworkIosArm64 FAILED
e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
Please try to disable compiler caches and rerun the build. To disable compiler caches, add the following line to the gradle.properties file in the project's root directory:
kotlin.native.cacheKind.iosArm64=none
Also, consider filing an issue with full Gradle log here: https://kotl.in/issue
The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FIRCrashlytics", referenced from:
objc-class-ref in libco.touchlab.crashkios:crashlytics-cache.a(result.o)
"_OBJC_CLASS_$_FIRExceptionModel", referenced from:
objc-class-ref in libco.touchlab.crashkios:crashlytics-cache.a(result.o)
"_OBJC_CLASS_$_FIRStackFrame", referenced from:
objc-class-ref in libco.touchlab.crashkios:crashlytics-cache.a(result.o)
ld: symbol(s) not found for architecture arm64
Execution failed for task ':core:linkDebugFrameworkIosArm64'.
> Compilation finished with errors
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
Having Kotlin 1.7.10 and Kermit 1.2.1-alpha, everything works fine.
Well, on the liner error, again, from the docs here: https://github.com/touchlab/CrashKiOS#linking
"If you are using dynamic frameworks, you'll see a linker error when building your framework."
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_FIRStackFrame", referenced from:
objc-class-ref in result.o
"_OBJC_CLASS_$_FIRExceptionModel", referenced from:
objc-class-ref in result.o
"_OBJC_CLASS_$_FIRCrashlytics", referenced from:
objc-class-ref in result.o
"_FIRCLSExceptionRecordNSException", referenced from:
_co_touchlab_crashkios_crashlytics_FIRCLSExceptionRecordNSException_wrapper0 in result.o
ld: symbol(s) not found for architecture x86_64
Please add branches that demonstrate the actual build failures. I don't want to keep editing your sample code to try to recreate the issues you're seeing. As in, please make the changes to your versions file, and put them in another branch. I would rather not keep trying to make local edits to recreate issues you're seeing.
I've recreated that issue in Kotlin 1.7.10 and Kermit 1.2.1-alpha. As I said, in your sample, you have CrashlyticsLogWriter()
commented out. When you uncomment that and run core:build
, it fails with the linker error, which again, is in the doc. It explains why you see that.
If you uncomment CrashlyticsLogWriter()
and get that to build successfully with Kotlin 1.7.10 and Kermit 1.2.1-alpha
, then I'm wrong. Please feel free to reopen, but also please update the sample.
I will update the Kermit docs, though, to make this more visible.
@kpgalligan just to give you a feedback on this:
Besides I had to add the co.touchlab.crashkios.crashlyticslink
gradle plugin, I had to set this on my binaries.framework config:
binaries.framework {
...
// necessary to make linker works with Kermit library
embedBitcode = BitcodeEmbeddingMode.DISABLE
}
And finally I have the project compiling and the Kermit working.
I don't know if this is necessary to use Kermit, can you confirm?
Kermit 1.2.1-alpha works fine.
Environment: macOS 12.6 Monterey 12.6 Xcode Version 14.1 (14B47b)