y

    yshrsmz

    3 years ago
    kotlin {
      iosX64('ios') {
        binaries {
          framework()
        }
      }
    }
    In 1.3.20 when I try to create framework for iOS with above config, looks like link task name is
    linkDebugFrameworkIos
    , but
    kotlin.targets.ios.compilations.main.linkTaskName('FRAMEWORK', 'DEBUG')
    is
    linkMainDebugFrameworkIos
    .
    i

    ilya.matveev

    3 years ago
    This is correct. Actually they are link tasks of different binaries. As you know, the
    compilation.outputKinds
    method was used to declare final binaries in 1.3.0. Such an approach allowed creating only one binary for each pair of binary kind (executable, framework etc) and build type (debug/release). So the
    compilations.main.linkTaskName('FRAMEWORK', 'DEBUG')
    returns the link task name for such a pair. In 1.3.20 the new API allows creating several binaries for the same compilation with the same kind and build type, so it's impossible to get a link task only by a pair of binary kind and build type. But almost all the APIs introduced in 1.3.0 were saved in 1.3.20 to make build scripts compatible. To achieve this, the plugin creates binaries for all kinds listed using the
    compilation.outputKinds
    method in addition to all binaries declared in the
    binaries
    block by a user. Thus the
    compilation.linkTaskName
    returns a link task name of a binary created using the
    compilation.outputKinds
    method, not a binary declared in the
    binaries
    block by a user. But you can get a link task of the second binary too:
    kotlin {
      iosX64('ios') {
        binaries {
          framework {
            println(linkTask.name)
          }
        }
      }
    }
    See also:https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#building-final-native-binaries.
    y

    yshrsmz

    3 years ago
    Thanks a lot! Now I can find link task and output file.
    def target = "ios"
    def binary = kotlin.targets."$target".compilations.main.target.binaries.findFramework("", "DEBUG")
    
    // binary.outputFile
    // binary.linkTask.name