https://kotlinlang.org logo
Title
r

Roman Levinzon

04/15/2023, 3:00 PM
Hello everyone 🙂 Using the new template https://github.com/JetBrains/compose-multiplatform-template Is there any way to setup @Preview for the
commonMain
? I want to create a shared design system and it would be handy to have it in there. Or I will have to have my Preview in say androidMain instead?
s

Stefan Oltmann

04/15/2023, 8:11 PM
Does this preview function work well for you? In my experience, it has always been very slow, to the point where starting the emulator and navigating to the view was much faster. Just curious.
a

Adam Brown

04/15/2023, 9:16 PM
no I've only gotten it to work in a desktop source set
r

Roman Levinzon

04/16/2023, 7:09 AM
Does this preview function work well for you?
Well I didn’t get to this point actually ;D First the Preview annotation was not available, makes sense I thought, there was no dependency. So I added that
implementation(comopose.preview)
in commonMain dep block
Aannnd got this
No matching variant of org.jetbrains.compose.ui:ui-tooling-preview:1.4.0 was found. The consumer was configured to find a library for use during 'kotlin-api', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64' but:
Thats actually means that none of the shared compose code is actually “previewable”, unless you go into android/desktop source sets and put your previews there…Unless I’m missing something
s

Stefan Oltmann

04/16/2023, 1:55 PM
I meant in general. The preview feature for Android is slow, so I didn’t try it for desktop.
x

xxfast

04/16/2023, 7:30 PM
I remember two years ago , the only way to get this working was to place all your previews in the android module, but hoping that has changed
r

Roman Levinzon

04/16/2023, 7:55 PM
That's my train of thought as well..I was hoping there's a better way to do it nowadays
a

Adam Brown

04/16/2023, 8:08 PM
it crashes less than it used to, so that's nice
you can't preview anything with a
Dialog
composable though