k

    Konstantin Petrukhnov

    2 years ago
    What are the current options for not implementing twice actual for ios arm/x64? I know it was mentioned multiple times in conversations during last few month. It is hard to dig through search and comments in slack.
    Is there anything like sample below that works? configure(iosX64) { sourceSets.dependsOn iosArm64 }
    alex009

    alex009

    2 years ago
    it allow not duplicate code and have gradle configs with both architectures enabled in same time. and IDE correct resolve all actuals
    k

    Konstantin Petrukhnov

    2 years ago
    Does it work on Windows? E.g. building targets that are not related to ios, running jvm/common tests, etc?
    alex009

    alex009

    2 years ago
    on windows symlink not same 😞 we use it just for ios, what not work on windows anyways, but for other targets symlinks not usefull i think
    k

    Konstantin Petrukhnov

    2 years ago
    I mean if I use symlink for ios targets, will I be able to build and run tests for common/jvm targets on windows?
    alex009

    alex009

    2 years ago
    yes. ios target disabled on windows as i know (but i not check self)
    k

    Konstantin Petrukhnov

    2 years ago
    thx, i will try
    m

    Marc Reichelt

    2 years ago
    I would recommend against symlinks because then something will go wrong on one platform. I’m trying to find out how we could define the same source set for both architectures in an easy way, so that way we have an answer for all new developers who want to go down that road
    louiscad

    louiscad

    2 years ago
    For now, symlinks and hitting cmd+S and cmd+option+Y is the best we got. This will no longer be necessary once HMPP (hierarchical multiplatform projects) is ready (should arrive in 1.3.70).
    Fudge

    Fudge

    2 years ago
    1.3.70? That’s exciting
    k

    Konstantin Petrukhnov

    2 years ago
    @louiscad where i could find more about HMPP?
    louiscad

    louiscad

    2 years ago
    In youtrack.jetbrains.com since it's still under development @Konstantin Petrukhnov
    Kris Wong

    Kris Wong

    2 years ago
    i would recommend against symlinks for a few reasons
    targets.withType<KotlinNativeTarget> {
            compilations["main"].defaultSourceSet {
                dependsOn(sourceSets["iosMain"])
            }
    
            binaries.framework {
                baseName = "${project.extra["iosFrameworkName"]}"
            }
        }
    alex009

    alex009

    2 years ago
    In this case IDE not recognize iosMain as iOS source set
    Kris Wong

    Kris Wong

    2 years ago
    you just need to name one of your iOS targets as "ios"
    in this case
    expect
    in common code will be show warning "iosX64 have not actual" ?
    Kris Wong

    Kris Wong

    2 years ago
    not if you do it right
    alex009

    alex009

    2 years ago
    when i try set two targets to one sourceset IDE show errors about one of
    actual
    where i can see "right" sample?) have you on github?
    Kris Wong

    Kris Wong

    2 years ago
    kotlin {
        jvm()
        iosX64("ios")
        iosArm32("iosArm32")
        iosArm64("iosArm64")
    
        ...
    
        targets.withType<KotlinNativeTarget> {
            compilations.getByName("main") {
                defaultSourceSet {
                    if (name != "iosMain") {
                        dependsOn(sourceSets["iosMain"])
                    }
                }
            }
            binaries.framework {
                baseName = "${project.extra["iosFrameworkName"]}"
            }
        }
    }
    alex009

    alex009

    2 years ago
    Thx, I will check 😃
    k

    Konstantin Petrukhnov

    2 years ago
    It seems I was able to use snippet below to solve all all issues. • compiles • only one source folder • actual correctly highlighted in IDE • expect highlight that there is no impl for iosX64 (only class name) • (bonus) no need for "iosMain" target
    kotlin {
    
      sourceSets {
    
        ios {
                kotlin.srcDirs += project.file("src/iosMain/kotlin")
                dependencies {
    
                }
            }
    
        iosX64 {
          dependsOn ios
        }
      }
    
      targets {
            //ios real device
            iosArm64("ios")
            //ios simulator
            iosX64("iosX64")
    
            configure([ios, iosX64]) {
                compilations.getByName("main") {
                    defaultSourceSet {
                        if (name != "ios") {
                            dependsOn(sourceSets["ios"])
                        }
                    }
                }
            }
        }
    }
    And that will fail, if you need to specify separate dependencies for arm/simulator 😞