How would I specify in my gradle file that the cod...
# kotlin-native
p
How would I specify in my gradle file that the code should be applicable to both the 64 bit and the 32 bit version of windows?
a
That can be done by providing an intermediate source set, adding it as a dependency for both of your mingw targets. Something like the old approach of iOS code sharing described here.
Copy code
sourceSets{
    mingwMain {
        dependsOn(commonMain)
        mingwX64Main.dependsOn(it)
        mingwX86Main.dependsOn(it)
    }
}
The problem here is that all platform libraries resolve can break up. In most cases, IDE just presumes the intermediate source set is just a common Kotlin code. There are several workarounds like enabling
Copy code
kotlin.mpp.enableGranularSourceSetsMetadata=true
in the project’s
gradle.properties
, but IIRC there are no guarantees for it’s help. 100% working method will be sharing all platform-independent code as a common, and duplicate all platform-dependent in both of the target’s default source sets(
mingwX64Main
,
mingwX86Main
).
🔥 1