compose-multiplatform
compose-multiplatform copied to clipboard
Using @Composable reified inline functions across modules fails to compile for iOS targets
Describe the bug
I have a simple @Composable
inline function with reified template parameters like this
@Composable
inline fun <reified C : Parcelable> rememberRouter(
stack: List<C>,
handleBackButton: Boolean = true
): Router<C> { ..}
compiling this for any ios target fails with
Shortly: The required symbol [ io.github.xxfast.krouter/rememberRouter|-3103101331561201202[0] <- local Local[<TP>,0 | TYPE_PARAMETER name:C index:0 variance: superTypes:[com.arkivanov.parcelize.darwin.Parcelable{ com.arkivanov.essenty.parcelable.Parcelable }] reified:false] ] is missing in the module or module dependencies. This could happen if the required dependency is missing in the project. Or if there is a dependency that has a different version (without the required symbol) in the project than the version (with the required symbol) that the module was initially compiled with.
I think i have all my dependencies set correctly so not sure why this is popping up ๐ค
However, this error goes away as soon as you make the same function not inline and not reified
@Composable
fun <C : Parcelable> rememberRouter(
type: KClass<C>,
stack: List<C>,
handleBackButton: Boolean = true
): Router<C>
Affected platforms Select one of the platforms below:
- iOS
Versions
- Kotlin version*: 1.8.10
- Compose Multiplatform version*: 1.3.1
- OS version(s)*: iOS 16.2
- OS architecture (x86 or arm64): arm64
To Reproduce Steps and/or the code snippet to reproduce the behavior:
- Checkout https://github.com/xxfast/NYTimes-KMP/pull/1/commits/3eea67c812b3e33530a4ac30e07919d76768712b
- Open xcode workspace and hit run
- Error on xcode build log on linking stage
Expected behavior
@Composable
inline function with reified template parameters to build and linked correctly.
Error on xcode build log on linking stage
Unfortunately, it fails earlier on my side with "unable to open configuration settings file".
Then I tried to copy-paste problematic code into https://github.com/JetBrains/compose-multiplatform-template
The compilation failed for @Composable fun rememberRouter
for iOS target because it is declared public. It is known issue (you reported two different issues on this recently) that we are fixing now. Making the function internal
fixes the problem even if I declare it as inline with reified generic parameter. Personally, I have no idea why the rememberRouter
is compiled now on your side without declaring it internal
but can you make it internal
and inline
with reified generic? We need to know if it is the same problem with internal
or not?
Thanks for the quick reply ๐ unfortunately, I need this to be not internal for another multiplatform multimodule project where this rememberRouter
exists in a :core
module that each of the :feature
modules consume.
Feel free to close #2901 and #2903 if they are all caused by the same underlying issue. I'll watch this issue for future updates ๐
With compose-multiplatform 1.5.10,. The error message is now updated to
Compilation failed: Symbol for [ io.github.xxfast.decompose.router/rememberRouter|rememberRouter(kotlin.Any;kotlin.Boolean;kotlin.Function0<kotlin.collections.List<0:0>>){0ยง<kotlin.Any>}[0] <- Local[<TP>,0|TYPE_PARAMETER name:C index:0 variance: superTypes:[kotlin.Any] reified:false] ] is unbound
I've updated the original issue description to match the observations from the latest findings