Rainer Schlonvoigt

01/07/2022, 2:24 PM
hey guys, our team is working on kotlin multiplatform code and we frequently run into the issue that kotlin’s
translates badly into Swift. While i understand why the language allows for it, i would like to forbid it for our own projects. Does anybody have an idea how to best achieve this?
this works in our setup, but seems clunky and i know that it doesn’t work with the newest kotlin version:
def iosFrameworkName = kotlin.cocoapods.frameworkName

['DEBUG', 'RELEASE'].forEach { config ->
    def frameworkArm64 = kotlin.targets.iosArm64.binaries.getFramework("${config}")
    def frameworkX64 = kotlin.targets.iosX64.binaries.getFramework("${config}")

    [frameworkArm64, frameworkX64].forEach { framework ->
        framework.linkTask.doLast {
            new File(framework.outputFile, "Headers/${iosFrameworkName}.h").eachLine {line ->
                if (line.contains('NSSet<id<')) {
                    throw new Exception("Stop using Set<SomeInterface> on public API! violater: $line")
Something that looks at the kotlin code would be nicer