https://kotlinlang.org logo
m

Mirzamehdi

06/02/2023, 5:31 PM
Hi all, currently is there any issue regarding adding @Composable annotation to some function inside some class in ios side? For example like this one:
Copy code
sealed interface UiMessage {

    data class Resource(val id: StringResource) : UiMessage
    data class Message(val message: String?) : UiMessage

    @Composable
    fun getMessage(): String {
        return when (this) {
            is Message -> this.message ?: ""
            is Resource -> stringResource(this.id)
        }
    }
}
Because in android side app works normally, but if I run this in ios side I get this error:
Copy code
e: There are still 1 unbound symbols after generation of IR module <shared>:
Unbound public symbol IrSimpleFunctionPublicSymbolImpl: com.mmk.common.ui.util/UiMessage.getMessage|6304721183059763253[0]
When I remove @Composable annotation from function, this error goes away
s

Sunil Kumar

06/03/2023, 3:48 AM
Try making getMessage internal , or you can use @HiddenFromObjC annotation as well on getMessage composable
m

Mirzamehdi

06/03/2023, 5:00 PM
the thing is it was inside another common module, and it couldn't be internal. As a workaround I made it as a top level function
d

Dima Avdeev

06/04/2023, 10:40 AM
Yeah, we have some bugs with the compiler plugin on the native part of Compose. You can try to use workaround described here: https://github.com/JetBrains/compose-multiplatform/issues/3216#issuecomment-1570152305
5 Views