JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.27k stars 1.18k forks source link

iOS, Voyager library compilation #3444

Closed LinkEdgar closed 1 month ago

LinkEdgar commented 1 year ago

Describe the bug Task :shared:linkPodDebugFrameworkIosSimulatorArm64 warning: Cannot infer a bundle ID from packages of source files and exported dependencies, use the bundle name instead: shared. Please specify the bundle ID explicitly using the -Xbinary=bundleId= compiler flag. error: Compilation failed: no implementation for FUN MISSING_DECLARATION name: visibility:public modality:FINAL <> () returnType:kotlin.Nothing in HomeTab This happens when using the Voyager navigation library specifically the Navigation Tabs. The project is the ios-android template with the addition of the voyager library for navigation. After testing out tab navigation I found that the iOS app would no longer work.

If the bug is Android-only, report it in the Jetpack Compose tracker

Versions

To Reproduce Steps and/or the code snippet to reproduce the behavior: Run the ios app

Expected behavior iOS app runs and builds

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

srikrishnacj commented 1 year ago

Hi, I am also facing the same issue error: Compilation failed: no implementation for FUN MISSING_DECLARATION name:BeforeContent visibility:public modality:FINAL <> () returnType:kotlin.Nothing

Sample code

abstract class Widget() : NewInitializer() {

    abstract fun init()

    @Composable
    protected abstract fun build()

    @Composable
    protected open fun BeforeContent() {
    }

    @Composable
    protected open fun InitializationInProgress() {
    }

    @Composable
    open fun Content() {
        val self = this

        val scope = rememberCoroutineScope()
        super.scope(scope)

        BeforeContent()

        DisposableEffect(key1 = Unit, effect = {
            super.scopedInitialization(true) { complete, waitUntil ->
                self.init()
                self.finished()
            }

            onDispose {
                scope.cancel("")
            }
        })

        RenderContent(scope)
    }

    @Composable
    private fun RenderContent(scope: CoroutineScope) {
        val initialized = super.initializationFeed().state(scope).value
        if (initialized) {
            this.build()
        } else {
            InitializationInProgress()
        }
    }
}
rajeshjaswal68 commented 1 year ago

Builds fine on Android and contineous to fail on iOS. Any solution yet?

Kotlin version: 1.9.0 Compose Multiplatform: 1.5.0-rc06

rezyfr commented 1 year ago

Builds fine on Android and contineous to fail on iOS. Any solution yet?

Kotlin version: 1.9.0 Compose Multiplatform: 1.5.0-rc06

use internal class on tab

ex: internal class HomeTab: Tab { }

Qw4z1 commented 1 year ago

Had a similar issue with the error message being: name:<get-icon> instead of name:BeforeContent.

The code is basically a copy paste from the example (see code below), which explicitly states:

Since tabs aren't usually reused, its OK to create them as object.

Changing the Tab implementation from object to internal class works for me, but maybe the documentation should be updated?

object HomeTab : Tab {

    override val options: TabOptions
        @Composable
        get() {
            val icon = rememberVectorPainter(Icons.Default.Home)

            return remember {
                TabOptions(
                    index = 0u,
                    title = "Home",
                    icon = icon
                )
            }
        }

    @Composable
    override fun Content() {
        HomeScreen().Content()
    }
}
okushnikov commented 4 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

okushnikov commented 4 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

okushnikov commented 4 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.