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

Using a public property extensions inside a class or object with a @Composable backing delegate fails to link for iOS targets #3084

Closed
MikolajKakol opened this issue Apr 21, 2023 · 13 comments
Assignees
Labels
bug Something isn't working compiler Compiler plugin related reproduced

Comments

@MikolajKakol
Copy link

Describe the bug
Given code should compile on iOS as it does on Android, similar to #2901

class G {
    val text: String @Composable get() = "Some text"
}

or

object G {
    val text: String @Composable get() = "Some text"
}

It fails with

error: There is still an unbound symbol after generation of IR module <shared>:
Unbound public symbol IrSimpleFunctionPublicSymbolImpl: /G.text.<get-text>|8349765969627210272[0]

Affected platforms
Select one of the platforms below:

  • iOS

Versions

  • Kotlin version*: 1.8.20
  • Compose Multiplatform version*: 1.4.0 and 1.5.0-dev1030
  • OS version(s)* (required for Desktop and iOS issues): 16.2
  • OS architecture (x86 or arm64): x86

To Reproduce
As in #2901

Expected behavior
It should compile

@MikolajKakol MikolajKakol added bug Something isn't working submitted labels Apr 21, 2023
@pablichjenkov
Copy link

pablichjenkov commented Apr 21, 2023

I can confirm this. I am using setters/getters extensions for the time being.

@eymar eymar added compiler Compiler plugin related reproduced and removed submitted labels Apr 24, 2023
@adtarassov
Copy link

I also have the same problem

@FireWookie
Copy link

i have this problem

@eymar
Copy link
Member

eymar commented May 22, 2023

There is a possible workaround described here: #3175 (comment)

One more option is to change the visibility of the class if it's okay:

private class G {...}
internal class G {...}

Also, as mentioned already by @pablichjenkov:

class G {...}

val G.text
  @Composable get() = "Some text"

It seems that in kotlin 1.9.0 it will be possible to add @HiddenFromObjC annotation to the class - https://youtrack.jetbrains.com/issue/KT-56464/K-N-Allow-HiddenFromObjC-for-classes
That annotation should fix this issue.
With kotlin 1.9.0, we'll patch the compiler plugin to add such an annotation automatically as we already do for functions. It's not possible to add this annotation in koltin 1.8.x to classes.

@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.

@pablichjenkov
Copy link

Indeed, the problem seems to be gone with above configuration. Thanks

@MikolajKakol
Copy link
Author

It doesn't quite work for me as

Compose Multiplatform 1.4.1 doesn't support Kotlin 1.8.21.

@eymar
Copy link
Member

eymar commented Jul 3, 2023

@MikolajKakol
as mentioned above, please add this to your build.gradle.kts with compose:

compose {
    kotlinCompilerPlugin.set("1.4.7")
}

In the next release, this step won't be needed.

@MikolajKakol
Copy link
Author

Yes, I added that in the shared module in the root and I saw that error message.
obraz

@eymar
Copy link
Member

eymar commented Jul 3, 2023

Is "wed" also a module?
The error message comes from the compose gradle plugin. So it's likely there are modules with compose.

@pablichjenkov
Copy link

You need to add bellow code in all modules build.gradle file.

compose { 
     // Sets a specific JetBrains Compose Compiler version 
     kotlinCompilerPlugin.set("1.4.7") 
     kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.8.21") 
 }

@MikolajKakol
Copy link
Author

That helped, I only added it for shared, sorry and thank you 😊

@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.

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 reproduced
Projects
None yet
Development

No branches or pull requests

7 participants