https://kotlinlang.org logo
f

fkrauthan

03/10/2020, 11:11 PM
And one last issue. I've created a multiplatform project that has
jvm
,
macosX64
and
linuxX64
as targets as well as a
commonMain
with most of my code and a
posixMain
source set where macos and linux main source sets are depending on. But for some reason I don't seem to have access to any of the default interops e,g,
platform.posix
nether in
posixMain
nor in
linuxMain
and
macosMain
. Is there anything else I need to configure to be able to access them (preferable in my
posixMain
source set?
r

russhwolf

03/10/2020, 11:35 PM
The IDE support with intermediate source-sets like that is lacking, but it should build from gradle/command-line
Can try setting
kotlin.mpp.enableGranularSourceSetsMetadata=true
in your
gradle.properties
which enables an experimental project model that will eventually make this work better. Might not help though.
f

fkrauthan

03/10/2020, 11:38 PM
But is there any way to not get red error warnings etc? E.g. manual add meta info for IDE?
r

russhwolf

03/10/2020, 11:40 PM
There’s various workarounds but all a little imperfect. You can do something like manually adding srcDirs from the shared code into your platform code. You get some IDE warnings but the inference works.
f

fkrauthan

03/10/2020, 11:43 PM
The strange thing is if I open the project structure it shows for posixMain that traget platform is
Native
How would you do the src Dirs workaround? Like I don't have an issue with accessing my common Kotlin code in my posixMain codebase but I get errors saying the import
platform
does not exist
r

russhwolf

03/10/2020, 11:49 PM
Right. It won't see platform things in intermediate sources
This is the workaround I use in Multiplatform Settings for shared apple stuff https://github.com/russhwolf/multiplatform-settings/blob/master/buildSrc/src/main/kotlin/BuildHelpers.kt#L107-L110
f

fkrauthan

03/10/2020, 11:52 PM
The strange thing is I don't even see it in the main native source targets like
linuxMain
r

russhwolf

03/10/2020, 11:52 PM
Not the only way to do it though. Other people might have better configs
f

fkrauthan

03/10/2020, 11:52 PM
Ok cool I check it out. Thank you very much
And you are right even though my IDE is not happy accessing cinterop works finish 😄
Hmm unfortunately your fix does not work for me 😞 I'll keep looking.