adrielcafe / voyager

🛸 A pragmatic navigation library for Jetpack Compose
https://voyager.adriel.cafe
MIT License
2.59k stars 138 forks source link

Tab Navigation not working for iOS build #179

Open LinkEdgar opened 1 year ago

LinkEdgar commented 1 year ago

Compose version: 1.4.3 Kotlin version : 1.9.0 After cloning the Compose KMM template found here https://github.com/JetBrains/compose-multiplatform-ios-android-template#readme, I added the Voyager library to test navigation. Everything seemed to work well until I added tab navigation this gave me the following issues

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

error: java.lang.IllegalStateException: no implementation for FUN MISSING_DECLARATION name: visibility:public modality:FINAL <> () returnType:kotlin.Nothing in HomeTab.

haoxikang commented 1 year ago

Do you fixed it? I have the same issue

LinkEdgar commented 1 year ago

Yes make you object/class internal and this will resolve the issue. Here is an issue link where I found the solution https://github.com/JetBrains/compose-multiplatform/issues/3175

paringer commented 1 year ago
Unbound public symbol IrSimpleFunctionPublicSymbolImpl: cafe.adriel.voyager.navigator.tab/Tab.icon.<get-icon>|-5764684600227404327[0]
Unbound public symbol IrSimpleFunctionPublicSymbolImpl: cafe.adriel.voyager.navigator.tab/Tab.options.<get-options>|7766868889533212780[0]
Unbound public symbol IrSimpleFunctionPublicSymbolImpl: cafe.adriel.voyager.navigator.tab/Tab.title.<get-title>|371973571756195065[0]

Hi, I have same problem, with voyager navigation, final data class TabOptions, used inside interface Tab, is not exported, it is either: does not open, final class, which was wrapped somehow unsuccessfully, or does not have generated getters and setters, or getters and setters are not exported, or interfaces can not have val fields after being exported, I have no idea, what wrong with compiler. It helped to use internal but I can not use object construction for tabs. @LinkEdgar Can you make these TabOptions normal open class ? Or may be empty get inside Tab class field options creates an issue ?

LinkEdgar commented 1 year ago

Here is an example of a working tab option I've used in my codebase @paringer . Let me know if this helps

internal object HomeTab : Tab {
    override val options: TabOptions
        @Composable
        get() {
            val title = "Home"
            val icon = rememberVectorPainter(Icons.Outlined.Home) // change to your own icon here

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

    @Composable
    override fun Content() {
        Navigator(HomePostsScreen) // change to any screen view you want to show here 
    }
}
paringer commented 1 year ago

@LinkEdgar Nice try :-) Please do not pretend to be stupid, you are definitely not, I have both, top tabs, and bottom tabs, in my project, and some nested inner tabs too, l and I want to extend classes somehow. Making classes internal helped me, but it is bad choice, because, I cannot extend it and I can not build my module with tabs as module, it forces me to make all my classes internal, and put all other classes in the same module, and I do not want to make it so, because, I added some fade/slide animation for tabs, cloned form yours SlideAnimation for Screen, thanks, for example, fixed some bugs with tabs, for that animation to work, ported to kotlin 1.9.0 and back to kotlin 1.8.20. And finally I can not extend TabOptions, because they are final, final data class TabOptions, which can be easily replaces by, normal, open class TabOptions able to be extended, and have different animations for different tab kinds. And more, that final class tiggers some iOS Konan Kotlin compiler/linker bug, which tries to wrap and extend every class used in interface, and fails, so TabOptions class descendants are not exported, and getters with it are not exported, and getters with getters to it are not exported, ios only, just because that cursed TabOptions is final. So can you change signature and make TabOptions open class ? Also would be nice to make navigator, constructor parameter of TabNavigator, public field, to allow tab animations access stack ? P.S. according to other messages, googled, linker has similar issue at generic interfaces with final classes at iOS too

LinkEdgar commented 1 year ago

Please don't pretend to be an asshole, you're definitely not. You know that I know that you know I have no idea what you intend to do with the tabs. I am just trying to help where I can. If it didn't solve your problem kindly ask someone else.

paringer commented 1 year ago

I am happy to hear that you have such a gorgeous sense of humor @LinkEdgar, but I thought you are able to contribute something to project, I did not meant to offend you, I will talk with someone else or contribute myself if possible, thanks for attention

nitesh-b commented 1 year ago

Here is an example of a working tab option I've used in my codebase @paringer . Let me know if this helps

internal object HomeTab : Tab {
    override val options: TabOptions
        @Composable
        get() {
            val title = "Home"
            val icon = rememberVectorPainter(Icons.Outlined.Home) // change to your own icon here

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

    @Composable
    override fun Content() {
        Navigator(HomePostsScreen) // change to any screen view you want to show here 
    }
}

Thanks a lot. Was scratching my head on this one..