Is there a way to implement expect functions in so...
# multiplatform
g
Is there a way to implement expect functions in source set groups, and, if not, are there plans to allow them in the future? I was just translating some Swift code that makes heavy use of macros to check for iOS, watchOS, tvOS, etc. I assumed this was already a feature and added an expect function in my
darwinMain
group with actual implementations in
iosMain
,
macosMain
, etc. The IDE couldn’t find the expect declaration, so I’m assuming this is not supported at the moment . Moving my expect declaration to
commonMain
with no-op implementations in the other source sets was an easy fix, but it’d be a nice quality of life feature (esp. on Apple platforms where I see this a lot).
Never mind, I figured it out. I forgot to add the following to my
kotlin.sourceSets
block 🤦:
Copy code
iosMain.dependsOn(darwinMain)
macosMain.dependsOn(darwinMain)
I’m using a custom hierarchy in my project so I can add a
jvmMain
that contains both
androidMain
and
desktopMain
(
jvm
target for Compose Multiplatform), so you have to link the sets together as part of the custom. hierarchy process. think I could have done this without a completely custom hierarchy, but honestly it works and that’s good enough for me 🤷 . I’ll explore modifying the default hierarchy the next time I have a free night.