Replies: 2 comments 7 replies
-
Could you please try using sealed class instead of sealed interface? See the example: |
Beta Was this translation helpful? Give feedback.
1 reply
-
Can you try printing the actual type of the |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using Decompose for navigation in a Kotlin Multiplatform project.
On Android everything works as expected.
However, in iOS (SwiftUI), I'm unable to cast a Child instance from the navigation ChildStack to its expected subclass.
Swift silently fails to match the correct subclass and falls into the default case — even though the runtime type is valid and visible in Swift.
Architecture Overview:
Navigation is defined in a
:core:navigation
module:build.gradle.kts related to
:core:navigation
module:In Android I use it this way and everything works as expected:
In Swift, I observe the current child using ObservableValue and attempt to render the correct view via casting:
The problem
Even though:
Swift fails to recognize the correct type and falls into the default case.
This seems to be caused by Swift's inability to cast sealed subclasses generated by Kotlin/Native interop (Objective-C) — even though the class hierarchy is intact and visible.
Is there a recommended way to expose Child subclasses from Decompose so that they can be safely distinguished and cast in Swift?
Thank you in advance!
Environment
kotlin: 2.1.10
decompose: 3.3.0
essenty-lifecycle: 2.5.0
Koin used for DI
iOS target: 16+
Beta Was this translation helpful? Give feedback.
All reactions