Can’t you use `platform` code in the `iosMain` sou...
# kotlin-native
r
Can’t you use
platform
code in the
iosMain
sourceSet that gets generated by adding the
ios()
target? If you can’t, why does it generates it anyway?
This new
ios()
target doesn’t seem to be documented actually
k
i don't see
ios
in
KotlinTargetContainerWithPresetFunctions
that would be ambiguous as a target
r
Well I do see it
It’s in
KotlinTargetContainerWithNativeShortcuts.kt
It creates
iosArm64
and
iosX64
targets and sourcesets
And an additional
iosMain
sourceSet which seems useless as IDEA doesn’t see
platform
Or maybe it’s just IDEA being wonky as usual
k
it's IDEA. i have had similar issues with it not handling the source sets propertly
a
k
i see the ios function, but I don't see where it creates an additional
iosMain
I had to name one of my iOS tagerts as "ios" in order for IDEA to work properly
then I just added a dependency on
iosMain
to my other iOS source sets
r
@Artyom Degtyarev [JB] thanks, that worked 🙂
@Kris Wong I think this is exactly what this new
ios()
shortcut is supposed to do: prevent you from having to do stuff to have proper ios targets. Previously I used symlinks
k
i don't it doing that anywhere in its code path
interesting that the new flag worked, though
r
Copy code
fun ios(
        namePrefix: String = "ios",
        configure: KotlinNativeTarget.() -> Unit = {}
    ) {
        val targets = listOf(
            iosArm64("${namePrefix}Arm64"),
            iosX64("${namePrefix}X64")
        )
        createIntermediateSourceSets(namePrefix, targets.defaultSourceSets(), mostCommonSourceSets())
        targets.forEach { it.configure() }
    }
That’s what it does
k
yes, i see it 🙂
l
The new gradle flag is picked up by the IDE (and Gradle too, for publication)