how should i be configuring my build script to use...
# multiplatform
r
how should i be configuring my build script to use generics? i tried following the documentation and digging into the PR that added generics support but i don't know if i'm doing it right
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xobjc-generics")
    }
}
I tried setting it up with the
Copy code
kotlin {
   ios {
        binaries.framework {
            freeCompilerArgs = freeCompilerArgs + "-Xobjc-generics"
        }
    }
}
And that was complaining about the name being the same
k
Copy code
freeCompilerArgs.add("-Xobjc-generics")
r
@Kris Wong huh okay, and where do I add that in my build file?
k
in your framework binary's config block
r
@Kris Wong I hate to be that guy, but do you happen to have an example of what that looks like? I'm super noob on configuring KMP. Thanks for your help
k
your second example is what I am talking about
r
@Kris Wong ah gotcha. i get this error when i try it
Copy code
freeCompilerArgs.add("-Xobjc-generics")
                                        ^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
                                            public inline fun DependencyHandler.add(configuration: String, dependencyNotation: String, dependencyConfiguration: ExternalModuleDependency.() -> Unit)
i think that the
freeCompilerArgs
at that point is a non-mutable
List
Copy code
ios {
        binaries.framework {
            freeCompilerArgs.add("-Xobjc-generics")
        }
    }
k
ah, then += operator should do the trick
r
right, okay. then it looks like this
Copy code
ios {
        binaries.framework("Generics") {
            freeCompilerArgs = freeCompilerArgs + "-Xobjc-generics"
        }
    }
i had to add the "Generics" name otherwise it wouldn't build
k
that's a problem because it's going to create 2 different frameworks
are you using the cocoapods plugin?
r
Yeah I am
looks like this @Kris Wong
Copy code
cocoapods {
        summary = "Common library for the KaMP starter kit"
        homepage = "<https://github.com/touchlab/KaMPStarter>"
    }
k
then you need to modify the framework it creates for you rather than creating a new one
r
ohhh, how does one do that? 😮
I looked through the docs for the plug-in but couldn't find anything on how to configure it @Kris Wong
alternatively you could use tasks.withType<KotlinNativeLink>().configureEach { ...
r
huh okay, thanks for your help. much appreciated i've been studying the kotlinconf gradle build file. looks like that might be a good option too https://github.com/JetBrains/kotlinconf-app/blob/master/common/build.gradle.kts
k
looks like there's a bunch of ways
r
yeah
@Kris Wong this worked for me and solved for my generics issue
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink>().configureEach {
    this.binary.freeCompilerArgs += "-Xobjc-generics"
}
k
technically replace binary with kotlinOptions
that's basically going link task -> binary -> link task -> kotlinOptions -> freeCompilerArgs
not a big deal
r
ah cool, good to know
thanks