Hi :) It seems that Compose previews are not bei...
# multiplatform
a
Hi :) It seems that Compose previews are not being displayed in a KMP project. Does anyone know how this could be solved?
p
Did you add:
Copy code
api(compose.uiTooling)
            api(compose.preview)
s
@Pablichjenkov Where do we put this??? commonMain ?
p
No, jvmMain and androidMain or both if you want to preview in both. For Android you need a couple of other lines in the Android specific configuration block
Copy code
buildFeatures {
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = "1.5.4"
    }
kotlinCompilerExtensionVersion above perhaps not the most recent.
s
Thanks for the information @Pablichjenkov just waiting for preview to support in KMM
👍 1
m
You can always add a @preview function in the android source set and display composables from the common source ser there.
a
Hi @Pablichjenkov I just noticed that dependencies start with api instead of implementation. Do you think that this affect the Compose Preview? Or maybe Compose Preview is not available for KMP yet.
p
No it doesn't affect it. Using
api
allows you to apply the dependencies in the common module and export it to consumer modules, so you don't write it twice or triple. Using
implementation
you will have to include the dependency in common module and also in each consumer module, it doesn't expose transitive dependencies.
1
a
Got it, thanks for pointing it out.
👍 1