Hello everyone :slightly_smiling_face: Using the n...
# multiplatform
r
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?
šŸ‘€ 1
s
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
no I've only gotten it to work in a desktop source set
r
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
Copy code
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
I meant in general. The preview feature for Android is slow, so I didn’t try it for desktop.
x
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
That's my train of thought as well..I was hoping there's a better way to do it nowadays
a
it crashes less than it used to, so that's nice
you can't preview anything with a
Dialog
composable though
j
@Roman Humyn hi, Did you ever find another way? It’s too hard to use preview only with androidMain.
r
No, seems like an only way unfortunately. It also kinda killed my hype about compose multiplatform altogether..šŸ˜… If you find any workaround let me know, would love to give it another shot