https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
t

Thomas Hormes

03/12/2024, 10:58 AM
I used the kmp.jetbrains.com project wizard to build a project with shared UI across Desktop, iOS and Android. I'm using Voyager for navigation and I also want to use screenModels. But, when I launch a coroutine using
ScreenModel
s
screenModelScope
on Desktop, I get an error "Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher....". Problem is: I have added
org.jetbrains.kotlinx:kotlinx-coroutines-swing
as advised here and even aligned the coroutines version to the one used by voyager (1.7.3). I also added
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm
but this did not help either. Has anybody encountered the same and has an idea as to what could be causing this? Is me building the project on an Apple M2 chip a problem?
a

albrechtroehm

03/14/2024, 8:41 AM
Which version of compose plugin you are using? I’m seeing a similar issue after i tried upgrading to version 1.6.0. When i go back to version 1.5.11 coroutines work just fine with the swing dependency for me. Getting a coroutineScope from compose-context via
rememberCoroutineScope
and passing that around works for some cases but since i use the gitlive-firebase sdk it still breaks my app since the sdk somewhere uses the the dispatchers as well (at least as far as i understood it) About M2: works fine for me as long as i don’t go for 1.6.0 🙂
t

Thomas Hormes

03/14/2024, 8:15 PM
Aha, that might be it. I'm also using gitlive, so it's good to know that. I'll try, when I get around to it on Monday or Tuesday when I'm back at work. Thanks Albrecht 🙂
a

albrechtroehm

04/01/2024, 8:34 PM
In case you still have issues I found a way to use compose v1.6.1 that works for me. I changed to usage of
Dispatchers.Main
to
Dispatchers.Default
in the gitlive-java-sdk and used that version. Works fine for me so far. But to be honest i would like to understand why there is issues with Main now even the swing-coroutines packages is there. But i did not have any insights there yet
p

Pedro Romano Barbosa

04/02/2024, 12:02 AM
I'm also facing the same exact problem. have you managed to solve this?
t

Thomas Hormes

04/02/2024, 7:57 AM
@Pedro Romano Barbosa No, I have not found a way to solve this issue yet. Albrechts solution might be worth looking into though
a

albrechtroehm

04/02/2024, 7:59 AM
I opened a Issue in the java-sdk, feel free to jump into that discussion as well
t

Thomas Hormes

04/08/2024, 9:32 AM
Seems to be working for me with the newest version of gitlive firebase 😊
a

albrechtroehm

04/08/2024, 9:49 AM
You're referring to the gitlive-kotlin-sdk 1.12.0? And you did not need to apply manual changes to the java-sdk? If so I should look into that and probably close the issue I reported.
t

Thomas Hormes

04/08/2024, 9:58 AM
Yes exactly, I just came back to the project, since I saw that gitlive published a new version. Only had to change the version to 1.12.0 and it works 😊
thank you color 1
🎉 1
a

albrechtroehm

04/08/2024, 10:28 PM
Really strange. It seems its not fixed for Windows. Only for MacOs. But for Windows changing to the
Dispatchers.Default
works ... 🤷
🤔 1