Reputation: 31
I am trying to make replacement of "expect fun A()" that have implementation in androidSourceSet with another implementation in mockSourceSet by using the android build flavor.
Structure of my project is
Android:App:
installed:
src
androidTest:
main:
<class App()>
mock:
<class App()>(there it works)
instant:...
Shared:
core:
src
androidMain
<actual fun A()>
androidMock
<actual fun A()>(to replace)
commonMain
iosMain
there is shared:core buildscript:
android {
compileSdk = Versions.compileSdk
defaultConfig {
minSdk = Versions.minSdk
}
flavorDimensions += "version"
productFlavors {
create("prod") {
dimension = "version"
}
create("mock") {
dimension = "version"
}
}
}
kotlin {
androidTarget()
iosX64()
iosArm64()
iosSimulatorArm64()
sourceSets {
commonMain.dependencies {
...
}
androidMain.dependencies {
...
}
iosMain.dependencies {
...
}
val androidMock by sourceSets.creating {
dependsOn(androidMain.get())
}
}
}
But i get error "Conflicting overloads: public actual fun A()" What approach i can use to have mock code organized and avoid if(buildType.value) blocks in production code?
Upvotes: 0
Views: 44