russhwolf / multiplatform-settings

A Kotlin Multiplatform library for saving simple key-value data
Apache License 2.0
1.69k stars 67 forks source link

Projects using the no-arg module fail to build in Kotlin 1.6.20 #106

Closed MarkRS-UK closed 2 years ago

MarkRS-UK commented 2 years ago

Trying to upgrade my project to 1.6.20 causes the iOS (but not Android) executable to fail. It complains

> Task :mobilemanegesharedmodule:linkDebugFrameworkIos FAILED
e: The symbol of unexpected type encountered during IR deserialization: IrSimpleFunctionPublicSymbolImpl, com.russhwolf.settings/Settings|-62081702699614493[0]. IrClassifierSymbol is expected.

This could happen if there are two libraries, where one library was compiled against the different version of the other library than the one currently used in the project. Please check that the project configuration is correct and has consistent versions of dependencies.

and then

+--- com.russhwolf:multiplatform-settings-no-arg (com.russhwolf:multiplatform-settings-no-arg-iosx64): 0.8.1
|    ^^^ This module contains symbol com.russhwolf.settings/Settings|-62081702699614493[0] that is the cause of the conflict.
|    +--- com.russhwolf:multiplatform-settings (com.russhwolf:multiplatform-settings-iosx64): 0.8.1
|    |    ^^^ This module contains symbol com.russhwolf.settings/Settings|-62081702699614493[0] that is the cause of the conflict.

Seems a little odd since I see you've already allowed for HMPP it seems. Perhaps it's Kermit causing the trouble?

marcorighini commented 2 years ago

Hi @russhwolf, is there a plan to release a version supporting kotlin 1.6.x in the short term? Thanks

russhwolf commented 2 years ago

The current version definitely works in 1.6.10. I haven't had a chance to look at what's happening here with 1.6.20, but should be able to take a look and put out an update if necessary in the next few days.

marcorighini commented 2 years ago

Considering that we are dealing in particular with kotlin native code, it would be safer in any case to have a version of the library compiled against the latest kotlin 1.6.20 version. What do you think?

russhwolf commented 2 years ago

@MarkRS-UK I'm able to reproduce the issue in the sample app by including the no-arg module. It doesn't seem to go away if I bump the library to 1.6.20, so I'm going to need to dig more. In the meantime, you can workaround by injecting your Settings instances from each platform instead of using no-arg.

@marcorighini Kotlin/Native has been experimentally backward-compatible since 1.4.0, and I'm not aware of any breakages since then. As such I have not been rushing to put out a library update each time there's a new Kotlin version.

MarkRS-UK commented 2 years ago

Yes, I've been using no-arg. I'll look at changing that.

russhwolf commented 2 years ago

I've been able to isolate this to an issue in Kotlin 1.6.20 and reported it on Youtrack. You can follow it here: https://youtrack.jetbrains.com/issue/KT-51927

russhwolf commented 2 years ago

I've confirmed that you can work around the issue while still using the current published version of the library by disabling compiler optimizations as recommended in the YouTrack ticket above. Add something like this to your gradle file:

kotlin {
    targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
        binaries.all {
            freeCompilerArgs += "-Xlazy-ir-for-caches=disable"
        }
    }
}
russhwolf commented 2 years ago

I've confirmed the issue is fixed in Kotlin 1.6.21. If you're using that Kotlin version, you should have no issues using the published version of the library.