https://kotlinlang.org logo
f

Francis Mariano

01/11/2023, 5:41 PM
hello, decompose already support compose for ios???
l

Landry Norris

01/11/2023, 5:44 PM
Versions ending in -native-compose should support iOS.
f

Francis Mariano

01/11/2023, 5:47 PM
ok, thank you very much
I am adding decompose in todo lite sample. Where can I create the root component on IOS side?? Maybe inside of MainViewController() ???
l

Landry Norris

01/11/2023, 7:57 PM
I would recommend creating it in the ViewController, similar to the Android activity. There’s no
defaultComponentContext
method for iOS yet, so you can pass
DefaultComponentContext(LifeCycleRegistry())
f

Francis Mariano

01/11/2023, 8:04 PM
ok.
DefaultComponentContext
I import from
com.arkivanov.decompose.DefaultComponentContext
. But
LifeCycleRegistry
i do not know
l

Landry Norris

01/11/2023, 8:05 PM
LifeCycleRegistry is from essenty. It should be included with decompose
import com.arkivanov.essenty.lifecycle.LifecycleRegistry
Looks like I got the capitalization wrong. It’s LifecycleRegistry
f

Francis Mariano

01/11/2023, 8:11 PM
tks a lot I got other error now
e: java.lang.IllegalStateException: No file for strobo.common.ui/StroboBasicContent
I gor that error for ios buid, but android is fine, stranger
l

Landry Norris

01/11/2023, 8:18 PM
Right now, Compose for iOS has several issues. For now, all Composable functions have to be internal or private, and can’t be inline.
Keep in mind that Compose for iOS is not yet production-ready. If you’re willing to deal with some limitations, it’s ready enough for experiments.
f

Francis Mariano

01/11/2023, 8:21 PM
success here. Ok, just for experiments now, but compose for iOS is great, congrats for all
l

Landry Norris

01/11/2023, 8:23 PM
From my experience using it, the main limitations right now are: 1. Visibility of methods as described above 2. Popups don’t call onDismiss when you tap outside 3. forEachGesture doesn’t properly handle
pressed
4. The canvas has a lower resolution than the screen (There’s a PR for this, though)
f

Francis Mariano

01/11/2023, 8:26 PM
what kind of problems you have with visibility of methods ???
l

Landry Norris

01/11/2023, 8:26 PM
Having to mark Composable methods as private or internal.
One could argue that it’s likely good practice to mark most Composables as internal, however. If you’re modularizing your app, you probably don’t want to leak info on the whole UI structure to other modules.
a

Arkadii Ivanov

01/12/2023, 12:36 AM
The main Decompose sample also supports Compose for iOS, it's in the
compose-darwin
branch - https://github.com/arkivanov/Decompose/tree/compose-darwin/sample/app-darwin-compose
It has plenty of public Composable functions. It worked a while ago, perhaps I should check it once again.
l

Landry Norris

01/12/2023, 1:37 AM
I think early versions did allow public composables, but it stopped working several versions ago (at least down to 1.2.0)
a

Arkadii Ivanov

01/12/2023, 8:45 AM
I have just checked, Decompose sample compiles and links just fine with public Composables. Compose 1.2.0, Kotlin 1.7.20. It's actually built on CI.
There is another issue that I recall, public expect/actual Composable functions with default parameter values were not compiling.
a

Adam Brown

01/12/2023, 8:01 PM
not exactly related, but i was really hoping this compose native work on iOS was eventually leading to fully native compose on desktop (no JVM), but some JB people said thats not on the road map as of right now 😒
l

Landry Norris

01/12/2023, 8:09 PM
I’d imagine that’ll change once iOS support is stable. I get that right now they don’t want to split their work too much.They already have to shift focus between iOS, desktop JVM, web, and web canvas. Adding 3 more targets this early on adds a lot of potential issues.
The desktop support also has a lot of experimental components (they’re about to rewrite scrollbar support, for example). If they support more desktop targets, those changes have a higher chance of breaking something.
a

Adam Brown

01/12/2023, 8:11 PM
ya true
l

Lee Taehoon

01/13/2023, 11:33 PM
In my experience, when exporting a composable function to the ios framework, the internal keyword must be attached. In the decompose sample, the ios main function is executed directly in the kmm project, so there is no problem. But if I export UIViewcontroller (Application composable function) written in kotlin to the framework, I need to use internal keyword.
l

Landry Norris

01/14/2023, 1:03 AM
Yes. The error occurs while building the framework. I forgot you could use main
27 Views