I have a KMP library I am developing for my apps, ...
# multiplatform
t
I have a KMP library I am developing for my apps, which target Android, iOS, watchOS, macOS. I want to include a KMP library that only supports Android and iOS. Is there a simple way for me to 'hide' that library from the unsupported platforms, but still put itin commonMain? Thank you
a
Not really. But you can create
mobileMain
and
notMobileMain
sourceSets and only write actuals twice
y
that could look like this if you are wondering
Copy code
kotlin {
    applyDefaultHierarchyTemplate {
        common {
            group("notMobileMain") {
                withMacos()
                withWatchos()
            }

            group("mobileMain") {
                withIos()
                withAndroidTarget()
            }
        }
    }
m
You could wrap it with a normal interface, then swap it at runtime on each platform. Just avoid expect/actual.
t
I already has a composablesMain where I put all the Compose stuff, since I need to build for watchOS too, so I adjusted the tree and put the moko-permissions in there. So far, so good.