Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose Compiler (iOS): public Composable functions in expect/actual class is attempted to be exported to ObjC #4848

Open
eymar opened this issue May 22, 2024 · 1 comment
Assignees
Labels
bug Something isn't working compiler Compiler plugin related ios regression

Comments

@eymar
Copy link
Collaborator

eymar commented May 22, 2024

When updating the jetsnack example to Kotlin 2, the iOS target won't compile:

e: Compilation failed: no implementation for FUN MISSING_DECLARATION name:shouldShowBottomBar visibility:public modality:FINAL <> () returnType:kotlin.Nothing

Affected platforms

  • iOS

Versions

  • Libraries:
    • Compose Multiplatform version: 1.6.10
  • Kotlin version: 2.0.0

To Reproduce

expect abstract class JetSnackCartViewModel() {
    @Composable
    fun collectOrderLinesAsState(flow: StateFlow<List<OrderLine>>): State<List<OrderLine>>
}

// Then an actual
actual abstract class JetSnackCartViewModel actual constructor()  {
    @Composable
    actual fun collectOrderLinesAsState(flow: StateFlow<List<OrderLine>>): State<List<OrderLine>> {
        return flow.collectAsState()
    }
}

The workaround is to add:

@OptIn(kotlin.experimental.ExperimentalObjCRefinement::class)
@HiddenFromObjC

on the actual class., or make the class internal.

@eymar eymar added bug Something isn't working compiler Compiler plugin related labels May 22, 2024
@eymar
Copy link
Collaborator Author

eymar commented May 22, 2024

Marking it as a regression, because there is no issue when using kotlin 1.9.2x
My guess is that the issue could be on Kotlin side, but only an investigation can confirm.


Another possible reason:
Maybe we skip 'expect' classes/functions in our lowering AddHiddenFromObjC. And k/native relies on them to create the exports in 2.0?

eymar added a commit that referenced this issue May 23, 2024
Changes:
- update all examples to Kotlin 2.0
- migrate to using kotlin("plugin.compose") for Compose compiler
configuration
- remove deprecated Compose Web gradle API usages

- added a workaround for
#4848 in
Jetsnack example


Testing:
- `./gradlew build` in every example
- run some examples in simulators (or desktop, browser)
eymar added a commit that referenced this issue May 29, 2024
Changes:
- update all examples to Kotlin 2.0
- migrate to using kotlin("plugin.compose") for Compose compiler
configuration
- remove deprecated Compose Web gradle API usages

- added a workaround for
#4848 in
Jetsnack example

Testing:
- `./gradlew build` in every example
- run some examples in simulators (or desktop, browser)

(cherry picked from commit 4c01cbd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler Compiler plugin related ios regression
Projects
None yet
Development

No branches or pull requests

2 participants