Hey I am just learning KMM. I found one repository...
# gradle
v
Hey I am just learning KMM. I found one repository in which some gradle code for creating for framework. I don't know about gradle code. Can some one guide me what is the piece of doing. It would really great for me.
Copy code
val packForXcode by tasks.creating(Sync::class) {
    val targetDir = File(buildDir, "xcode-frameworks")

    /// selecting the right configuration for the iOS
    /// framework depending on the environment
    /// variables set by Xcode build
    val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
    val framework = kotlin.targets
        .getByName<KotlinNativeTarget>("ios")
        .binaries.getFramework(mode)
    inputs.property("mode", mode)
    dependsOn(framework.linkTask)

    from({ framework.outputDirectory })
    into(targetDir)

    /// generate a helpful ./gradlew wrapper with embedded Java path
    doLast {
        val gradlew = File(targetDir, "gradlew")
        gradlew.writeText("#!/bin/bash\n"
            + "export 'JAVA_HOME=${System.getProperty("java.home")}'\n"
            + "cd '${rootProject.rootDir}'\n"
            + "./gradlew \$@\n")
        gradlew.setExecutable(true)
    }
}

tasks.getByName("build").dependsOn(packForXcode)
build.gradle.kts
s
The most pertinent bits are the
tasks.creating(Sync::class)
and the
from
and
into
directives
The code you shared is creating a new task that syncs files from one directory into another
You can look at the docs for the sync task to learn more about how that works
All the other code is just applying some minor customisations to the task and the files that get copied
v
Thanks @Sam I'll learn from the doc