I have code in an iosMain source set that's shared...
# kotlin-native
e
I have code in an iosMain source set that's shared between the iosArm64 and iosX86 targets. With this setup, I'm not able to get code completion for iOS platform calls in Intellij. Is there a way to instruct it to use one of the two iOS targets just for the purposes of code completion in the editor?
k
i haven't come across a workaround, but I haven't looked very hard. it's definitely a huge pain.
can you just use one target for the time being as a workaround?
k
I “cheat” a bit. Assuming there’s some form of
nativeMain
and
nativeTest
that is the base source set, I keep a target commented out, uncomment and refresh Intellij to get code completion to work. Make sure to comment out before building, though
Copy code
nativeMain {
      dependsOn commonMain
    }
    nativeTest {
      dependsOn commonTest
    }

    configure([iosX64Main, iosArm64Main, linuxX64Main, macosX64Main]) {
      dependsOn nativeMain
    }
    configure([iosX64Test, iosArm64Test, linuxX64Test, macosX64Test]) {
      dependsOn nativeTest
    }
Copy code
iosX64()
  iosArm64()
  macosX64()
//  macosX64("native")
Uncomment the last and refresh
k
anyone know if there's a youtrack issue for this?
if that works, couldn't you just name one of your targets to match the source set name?
Copy code
iosX64('iOS')
iosArm32()
iosArm64()
k
Probably? I’ve tried it in the past and had issues, but I’m not sure you’d still have them.
k
i'll give that a try
r
There are 2 better solutions for this, you either have one folder in src like iosMain and create simlinks for instead of the other folders, or you can also just add the sources from one target to another in the build.gradle
🤘 1
👍 1
I personally use symlinks because I know that nobody will use the project on a platform that does not support symlinks
Setting up stuff in Gradle is more portable
k
hot damn. that works!
r
Yeah that’s why I prefer symlinks lol
k
i prefer to have the complete project configuration in the gradle files
r
Another thing you can do that's a bit of a hack is have interdependencies, like iosX64 depend on iosArm64. Here's what I do in Multiplatform Settings https://github.com/russhwolf/multiplatform-settings/blob/master/multiplatform-settings/build.gradle.kts#L98-L112
This can cause some other redlines where the IDE thinks there's missing `actual`s but on balance I find that easier to deal with
k
At the end of your source sets, config the source sets
Copy code
configure([iosArm32Main, iosArm64Main]) {
      dependsOn iosMain
    }

    configure([iosArm32Test, iosArm64Test]) {
      dependsOn iosTest
    }
In targets, consolidate framework config
Copy code
configure([ios, iosArm32, iosArm64]) {
            binaries.framework {
                baseName = "$ios_framework_name"
            }
        }
🍻 1
💯 1
r
Also regarding youtrack, https://youtrack.jetbrains.com/issue/KT-27801 is a parent for a number of related issues.
k
now the only red I have is related to conflicting overloads
since CONFLICTING_OVERLOADS doesn't seem to fix that
e
Based on the YouTrack, it sounds like there's a bunch of work being done in this area, which is good to hear. I guess I'll continue manually editing the Gradle script for now.
a
last variant what we used (& for now it best for us) - create symlinks:
Copy code
ln -s iosMain iosArm64Main
ln -s iosMain iosX64Main
with it IDE correct see expect/actual, we have both arch gradle tasks and not duplicate files - all in iosMain directory
k
this works great
e
Storing symlinks in SCM can create headaches for anyone building on Windows. There are options to make it work in Git, but it's not part of the default configuration.
a
ios can't compile on windows anyways 🙂
e
Fair point. 🙂 In this case, the paths not getting linked right probably won't break anything.