Hi, if I want to put task outside kotlin block how...
# kotlin-native
v
Hi, if I want to put task outside kotlin block how can I get “ios32” and “ios64" this two KotlinNativeTarget like XXX.targetName Thanks
g
This should work
Copy code
val ios32 = kotlin.iosArm32()
v
Yes, but it is local variable
g
what do you mean?
v
Copy code
kotlin {
    targets {
        val iOSArm64 = iosArm64(targetNameIOSArm64) {
        }

        val iOSX64 = iosX64(targetNameIOSX64) {
        }
    }
}

tasks.create("debugFatFramework", FatFrameworkTask::class) {
    group = groupNameIOSFatFramework

    // The fat framework must have the same base name as the initial frameworks.
    baseName = exportFrameworkNameIOS

    // The default destination directory is '<build directory>/fat-framework'.
    destinationDir = buildDir.resolve("fat-framework/debugFramework")

    // Specify the frameworks to be merged.
    from(
        iOSArm64.binaries.getFramework("DEBUG"), // iOSArm64 can't found
        iOSX64.binaries.getFramework("DEBUG") // iOSX64 can't found
    )
}
any property can get iOSArm64/iOSX64 directly, without using global var
g
Still not sure what you mean. As I said, just move those properties out of Kotlin block and reference them directly:
Copy code
val iOSArm64 = kotlin.iosArm64(targetNameIOSArm64 { /* some config */ }
val iOSX64 = kotlin.iosX64(targetNameIOSX64) { }
k
more simply, just precede the target with
kotlin.
v
Finially, I use
Copy code
(kotlin.targets.findByName("iOSArm64") as KotlinNativeTarget).binaries.getFramework("DEBUG"),
Thanks everyone.
k
kotlin.targets.ios.binaries.getFramework("DEBUG")
g
kotlin.targets.ios.binaries.getFramework(“DEBUG”)
Will not work on Kotlin DSL, because
kotlin.targets
is not exposed as propery, only as configuration block
(kotlin.targets.findByName(“iOSArm64”) as KotlinNativeTarget).binaries.getFramework(“DEBUG”)
I don’t understand why you want to get this configuration by name, if you can just save it to local variable and reuse