Has anyone here got `commonMain` Preview working? ...
# compose-desktop
d
Has anyone here got
commonMain
Preview working? I cannot, for the life of me, make this work in IntelliJ IDEA 2025.1.3. I'm using Compose
1.9.0-beta3
, tried with & without Android Multiplatform plugin installed, of course including in `commonMain`:
Copy code
implementation(compose.components.uiToolingPreview)
...the gutter or preview options never light up on my
@Preview
's. What's the trick!? I hope
1.9.0
comes with some instructions because whatever it is, it must be a very fickle set of configurations and sure as hell is not obvious! kodee grumpy The years of my life wasted trying to get common previews (since CfD released) are going to stop being measured in fractions soon.
p
Not sure if things have changed in the mp world but is usually 2 dependencies. uiTooling and uiToolingPreview
d
Thanks @Pablichjenkov, but...
Copy code
implementation(compose.uiTooling)
...doesn't resolve from
commonMain
I will try in platform source-sets and see if that enables things.
Nope. Look, I'm obviously missing something, but I'm also no dummy when it comes to configuring Compose - I've been doing it for years, experimental Dev repo's, manual compiler plugin configs, disabling caches on native, cobbling together some kind of
commonMain
support with expect/actuals; I've been there: So here it goes, I'm sending the [JB] distress flare, look at this:
...I know it's not an officially supported feature yet, but if Compose
1.9.0
gets released with
commonMain
Preview as a feature, it had better actually be documented and not just 'thrown over the wall', because I'm not sure [JB] Devs appreciate how confusing this is to configure. Debugging K/N freezing memory model issues was a walk in the park compared to this one. Youtrack shows: users really want this, and it's really hard to get at. This should be CMP projects #1 priority - and I would have said that for a long time. Previews are one of Compose's greatest productivity strengths, but take them into the KMP context and Previews are practically unusable without
commonMain
support. Who wants to be manually navigating between source sets and re-setting split panes across source sets just to get a common component into view? The current UX sucks.
1
p
Humm 🤔 I do recall watching a video where someone was able to make it work
i
hey Chris, quick question: do you have an Android target in your project? Currently preview functionality depends quite a lot on that.
d
Hi @Ilia Bogdanovich [JetBrains]; yes I do have an Android target using the new KMP Android Library plugin (this is in the
shared
module of a KMP App). The
commonMain
source set has:
Copy code
implementation(compose.components.uiToolingPreview)
...while the
androidMain
source set has:
Copy code
implementation(compose.uiTooling)
I guess I will just wait until
1.9.0
is released and this feature is supported; hopefully it'll come with clear instructions at that point.
i
so the problem is that you don't see the gutter icon to launch your preview on the emulator, did I get your issue correctly? do you see the preview splitter itself, at the top-right corner? If the answer is no, you most likely don't have the required plugins installed (all three are mandatory): • Android • Android Design Tools • Jetpack Compose