I'm having trouble with some ide setup using kotli...
# kotlin-native
p
I'm having trouble with some ide setup using kotlin native. I created a mpp project and now consumed that from a regular android library. When I click on a class definition, it shows me only a decompiled class file and not the actual sources. And it seems that all dependencies are not propagated correctly. I.e I'm using flow in my mpp library but when I want to use functions from the library that return a flow it says that kotlin.coroutines.flow is not in my classpath. (but it is and it compiles correctly) Any hints on how to fix these issues?
k
there is usually an option at the top of the editor for decompiled classes to specify the sources
p
But its code from the same repo
k
it sounds like maybe you have a source set whose name does not match the name of any target
that confuses IDEA
more specifically it confuses the KMP plugin
p
How would I fix that?
k
either change one of your target names, or change the source set name, so they match. i.e., target "android" has source set "androidMain", etc...
i can't say for sure that's your problem based on the behavior you describe, but it may be the problem
p
Hm can you check the example? It's straight cloned from the official example with very minimal modifications
k
the example is correct
i don't see any reason you would experience the behavior you describe
l
You have an open source reproducer, and you can give some details. That's wonderful to have, you can make a good bug report on kotl.in/issue
r
In your common dependencies, try changing
kotlinx-coroutines-core-common
to
kotlinx-coroutines-core-native
. Under the hood, you need both common and platform dependencies, or you can use a metadata-enabled dependency which knows how to fetch the platform dependencies from a single artifact. For historical reasons that metadata artifact is called
-native
on most of the kotlinx libraries, though that will change in 1.4 to make it less confusing.
p
@russhwolf Hm, the readme says that the core-native package is for native. https://github.com/Kotlin/kotlinx.coroutines#native