Joffrey
06/08/2022, 9:23 AMA compileOnly dependency is used in the Kotlin/Native target 'iosArm64'
The commonMain source set indeed declares kotlinx-serialization-json as a compileOnly dependency. This is what I want for non-native targets (JVM, JS browser, JS node...) because I don't want to force this JSON-specific dependency onto users that want to use other serialization formats, but I do want to add a couple JSON-specific helper functions for ease of use if they do add the JSON dep on their end.
So I have a couple questions:
1. is this actually a problem? I mean, by default it's supposed to compile the native targets to a klib (not a linked binary) so why is this a problem? Shouldn't it be a problem on the consumer side when actually building a final binary?
2. if it is a problem, how can I solve it? I tried to add this dependency as implementation inside the iosMain source set, but it doesn't seem to solve the warning. Is my only option to split my module into 2 modules, one with an implementation dependency on kotlinx-serialization-json and one without the dependency?
I'm tempted to just disable the warning with kotlin.native.ignoreIncorrectDependencies=true but I'd like to understand better if it's really a problem firstephemient
06/08/2022, 9:29 AMJoffrey
06/08/2022, 10:08 AMJoffrey
06/08/2022, 12:32 PMcompileOnly does seem to be the cause of the above bug on the consumer side of Krossbow. So it is indeed an actual problem.
Apparently this is due to problems with caching on Native: https://youtrack.jetbrains.com/issue/KT-46377
A workaround on the consumer side is to disable caching:
kotlin.native.cacheKind=none
But the best option is likely to avoid compileOnly altogether on library side, which is unfortunate.