hey guys, our team is working on kotlin multiplatf...
# build-tools
r
hey guys, our team is working on kotlin multiplatform code and we frequently run into the issue that kotlin’s
Set<SomeInterface>
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:
Copy code
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