Open igordmn opened 1 month ago
Sub-issue: project created by kmp.jetbrains.com doesn't support Preview in IDEA/Android Studio https://github.com/JetBrains/compose-multiplatform/issues/4839
I agree that we have to either use the Android one for compability or the one from Jetbrains compose multiplatform as it's more future proof.
Preview an UI in commonMain
on IntelliJ IDEA that is what I want.
+1 Getting multiplatform compose previews to work in different places is currently a hassle.
A report in Kotlin IDEA plugin tracker: https://youtrack.jetbrains.com/issue/KTIJ-30072
For anyone else who finds this, I've found a solution that fits my needs while waiting for better preview support in Compose Multiplatform and Android Studio.
I was able to use the new Compose Preview Screenshot Testing library inside fully KMP / Compose multiplatform modules.
Previews work inside Android Studio under the proper package, and this (mostly) solves my screenshot testing needs as well. Obviously there are some requirements like putting previews in the screenshotTesting
source directory, require an Android target with AGP 8.5.0, and only being able to pull from the common/android sources.
Here's the Gradle convention plugin I'm using to apply to the relevant modules: https://gist.github.com/malbanese/6f015e0390ee767c4bc0acb87f697755
We have 3 Previews:
androidx.compose.ui.tooling.preview.Preview
build.gradle
should haveimplementation(compose.preview)
androidx.compose.desktop.ui.tooling.preview.Preview
build.gradle
org.jetbrains.compose.ui.tooling.preview.Preview
build.gradle
should haveimplementation(compose.components.uiToolingPreview)
We should reduce the count, and make consistent guidelines/templates.