Asad Mukhtar

    Asad Mukhtar

    1 month ago
    Hi, everyone can you please let me know, can i use Compose for building Android UI, and swiftUI for IOS in KMM project?
    hfhbd

    hfhbd

    1 month ago
    First of all: Native Swift support is not supported, because Kotlin does only support Objective-C. Next, it depends on your definition of Compose 😄 If you mean Compose UI, it is a UI framework which stable version currently does not support iOS. Alpha versions of JetBrains Compose support iOS and for SwiftUI you need the wrapper: https://developer.apple.com/tutorials/swiftui/interfacing-with-uikit. See the ios examples https://github.com/JetBrains/compose-jb/tree/master/experimental/examples/falling-balls-mpp. Alternatively, you can share everything but UI, so Data, Business logic, ViewModels, Networking, etc with Kotlin Multiplatform and implement your UI with Compose UI on Android/Desktop, and implement the UI for iOS using SwiftUI. This is done in my sample https://github.com/hfhbd/ComposeTodo or at https://github.com/joreilly/PeopleInSpace
    Konstantin Tskhovrebov

    Konstantin Tskhovrebov

    1 month ago
    Paul Woitaschek

    Paul Woitaschek

    1 month ago
    I wonder though if it's possible to use compose without compose UI and consume a composable function from swift.
    hfhbd

    hfhbd

    1 month ago
    I guess, it is possible, and what Cash does with redwood https://jakewharton.com/multiplatform-compose-and-gradle-module-metadata-abuse/. But you still have to implement the Swift compose applier. Open question is the implementation because lacking swift support from Kotlin. And what do you want to share with compose? For data, you could use Flows instead, which works almost out of the box with Swift.
    Paul Woitaschek

    Paul Woitaschek

    1 month ago
    A view state. Using regular composables on droid and molecule on iOS should work
    hfhbd

    hfhbd

    1 month ago
    I guess redwood does exactly this. It fits perfectly into cash projects with molecule. Just wait until september 1: https://nyc.droidcon.com/jake-wharton/