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

[iOS] Compile error when using delegated property with @Composable getters in objects #3216

Closed
JunkFood02 opened this issue May 29, 2023 · 9 comments
Assignees
Labels
bug Something isn't working compiler Compiler plugin related ios

Comments

@JunkFood02
Copy link

Affected platforms
Select one of the platforms below:

  • iOS

Versions
Using the Compose for iOS template

To Reproduce
Sample code:

object Surfaces {
    val surfaceDim: Color
        @Composable
        get() = Color.Transparent
}

Error report

> Task :shared:linkPodDebugFrameworkIosSimulatorArm64 FAILED
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=<id> compiler flag.
error: There is still an unbound symbol after generation of IR module <shared>:
Unbound public symbol IrSimpleFunctionPublicSymbolImpl: theme/Surfaces.surfaceDim.<get-surfaceDim>|-917462939767848401[0]

This could happen if there are two libraries, where one library was compiled against the different version of the other library than the one currently used in the project. Please check that the project configuration is correct and has consistent versions of dependencies.
error: Compilation finished with errors

Additional context

This only happens with getter annotated with @Composable in object or companion object of classes. Declare such functions at the top level of file won't cause this issue.

@JunkFood02 JunkFood02 added bug Something isn't working submitted labels May 29, 2023
@dima-avdeev-jb dima-avdeev-jb self-assigned this May 29, 2023
@dima-avdeev-jb dima-avdeev-jb added compiler Compiler plugin related ios and removed submitted labels May 29, 2023
@eymar
Copy link
Member

eymar commented May 31, 2023

This was fixed in compose multiplatform compiler plugin 1.4.7-rc01. It will be included automatically in the next compose multiplatform release.

It requires kotlin 1.8.21.

For now it can be enabled like this:

compose {
    kotlinCompilerPlugin.set("org.jetbrains.compose.compiler:compiler:1.4.7-rc01")
   // kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.8.20") // add this only if you want to use kotlin 1.8.20 instead of 1.8.21
}

@jershell
Copy link

jershell commented Jun 1, 2023

i think i have a simular problem.

Unbound public symbol IrSimpleFunctionPublicSymbolImpl: androidx.compose.runtime.saveable/SaveableStateHolder.SaveableStateProvider|453623736503830011[0]

I used compiler:1.4.7-rc01 & kotlin 1.8.21 but i have same error.

@jershell
Copy link

jershell commented Jun 2, 2023

Okay i get it. How to reproduce

  1. Create a class
package com.pkg

import androidx.compose.runtime.Composable
import androidx.compose.runtime.saveable.SaveableStateHolder

class Foo: SaveableStateHolder {
    @Composable override fun SaveableStateProvider(key: Any, content: @Composable () -> Unit) {
    }

    override fun removeState(key: Any) {
    }
    override fun toString(): String {
        return "bar"
    }
}
  1. use it in App.kt.
        var greetingText by remember { mutableStateOf("Hello, World! ${Foo()} ") }

This simple case for overview. I never call SaveableStateHolder inheritance and I get an error message

error: There is still an unbound symbol after generation of IR module <shared>: Unbound public symbol IrSimpleFunctionPublicSymbolImpl: androidx.compose.runtime.saveable/SaveableStateHolder.SaveableStateProvider|453623736503830011[0]

i used

compose {
    kotlinCompilerPlugin.set("org.jetbrains.compose.compiler:compiler:1.4.7-rc01")
    kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.8.21") 
}

its not work for me.

@eymar
Copy link
Member

eymar commented Jun 2, 2023

@jershell the problem you're describing is a bit different (it's not about a getter).
It should be fixed in 1.4.1 (not released yet).


Does your class need to be public? One of the workarounds is to make it internal if applicable in your case.

@jershell
Copy link

jershell commented Jun 2, 2023

@eymar I never call this class. I think some dependency call this class inside. I dont now how to search what a class do it.

@xiaobailong24
Copy link

workaround

object Surfaces {
    @Composable
    fun surfaceDim(): Color = Color.Transparent
}

@eymar
Copy link
Member

eymar commented Jun 28, 2023

Hey everyone!
The bugs were fixed. Please update to 1.4.1 Compose Multiplatform, and use kotlin 1.8.21 with

compose {
    kotlinCompilerPlugin.set("1.4.7")
}

In the next release, setting kotlinCompilerPlugin.set("1.4.7") won't be necessary.

@igordmn
Copy link
Collaborator

igordmn commented Jul 26, 2023

Fixed in 1.4.3

@igordmn igordmn closed this as completed Jul 26, 2023
@okushnikov
Copy link
Collaborator

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

@JetBrains JetBrains locked and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working compiler Compiler plugin related ios
Projects
None yet
Development

No branches or pull requests

7 participants