https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
k

Kirill Zhukov

02/22/2023, 10:45 PM
Is it possible to create compilation based source sets? I want to have some common
expect
function that has different implementation based on compilation type (debug vs release basically), how would I set that up?
👍 1
b

Big Chungus

02/23/2023, 12:37 AM
I doubt it, but would be glad to be proven wrong here.
k

Kirill Zhukov

02/23/2023, 12:37 AM
What I’m looking for is a setup like this:
Copy code
// commonMain
expect fun foo(): String

// commonRelease
actual fun foo(): String = "release"

// commonDebug
actual fun foo(): String = "debug"
It looks like I might need to create
debug
and
release
compilations and wire them up to each target; along with new
commonRelease
and
commonDebug
source sets?
Setting this up seems pretty painful 😕
One option I’m considering is to use generated build flavor: https://github.com/yshrsmz/BuildKonfig.
x

xxfast

03/14/2023, 2:24 AM
Even with BuildKonfig - there's no real way to do this. This is because common sources doesn't distinguish between release and debug sources
6 Views