Hi. I am encountering difficulties with exporting ...
# decompose
c
Hi. I am encountering difficulties with exporting and using decompose in iOS application that employs SwiftUI and Compose Multiplatform. I followed the documentation for exporting. After compiling the shared code without any errors, I began by copying the helper functions into the swift files. However, I can not see the correct components such as Cancellation, Value, MutableValue … Can you help me to resolve the issue? Thank you for your time and effort!
targets
._filterIsInstance_<KotlinNativeTarget>()
._filter_ *{ it*.konanTarget.family == Family._IOS_ *}*
._forEach_ *{*
*it*.binaries.framework *{*
baseName = frameworkName
export(_libs_._decompose_)
export(_libs_._essenty_._lifecycle_)
}
}
I use the following versions: •
Kotlin: "1.9.21"
Compose Multiplatform: "1.6.0-alpha01"
Decompose: "3.0.0-alpha04"
Essenty: "2.0.0-alpha02"
My dependencies are configured as follows: In `commonMain`: •
implementation(libs.decompose)
implementation(libs.decompose.extension)
api(libs.essenty.lifecycle)
api(libs.essenty.lifecycle.coroutines)
In `iosMain`: •
api(libs.decompose)
a
They are, but for some reason prefixed with Decompose.
c
But for example
MutableValue
is not present even as
DecomposeMutableValue
.
a
Got it. Are you using cocoapods?
c
There is a cocoapods integration in the project. I also tried to export it by using the cocapods. However, the result is the same.
a
Some people had issues with cocoapods, I usually advise to not use cocoapods unless you need pod dependencies in your Kotlin code. There is just no reason of using cocoapods otherwise. The issue you are having looks similar to: https://kotlinlang.slack.com/archives/C03H3N51SKT/p1683835812986759?thread_ts=1683725214.780229&amp;cid=C03H3N51SKT
It would be good to finally catch this bug with a reproducer, I would report it to JB.
c
I see. I went through that discussion yesterday and tried the mentioned solution. In case I missed a point yesterday, I quickly went through your solution again but I have the same result. Do you have any other idea I can try?
a
I don't have any ideas other than creating a reproducer project. Sorry. Decompose is a normal library, and sometimes it's not exported even though it should be. Only entities directly used in your shared module are exported, but the rest is not. It's clearly a bug in KMP, assuming you exported everything correctly.
Did you try exporting all Essenty dependencies, as mentioned in my comment in that thread?
Here is a reproducer for another (unrelated) bug, I think it uses cocoapods and everything is exported just fine. Maybe it will help. https://github.com/Gra-Dus/UIOSChildSampleError/tree/master
c
Yes, I tried exporting all with cocoapods and regular framework as below but didn’t work. Thank you I will inspect the reproducer you shared. May be I can use it to reproduce my error.
_cocoapods_ *{*
framework *{*
baseName = frameworkName
export(_libs_._decompose_)
export(_libs_._essenty_._lifecycle_)
export(_libs_._essenty_._stateKeeper_)
export(_libs_._essenty_._instanceKeeper_)
export(_libs_._essenty_._backHandler_)
}
}
val iosMain by _creating_ *{*
dependencies *{*
api(_libs_._decompose_)
api(_libs_._essenty_._lifecycle_)
api(_libs_._essenty_._stateKeeper_)
api(_libs_._essenty_._instanceKeeper_)
api(_libs_._essenty_._backHandler_)
}
}
essenty-lifecycle = { group = "com.arkivanov.essenty", name = "lifecycle", version.ref = "essenty" }
essenty-stateKeeper = { group = "com.arkivanov.essenty", name = "state-keeper", version.ref = "essenty" }
essenty-instanceKeeper = { group = "com.arkivanov.essenty", name = "instance-keeper", version.ref = "essenty" }
essenty-backHandler = { group = "com.arkivanov.essenty", name = "back-handler", version.ref = "essenty" }
a
If it's not working with regular integration, then something should be wrong with the setup, I guess.
Or another KMP bug
c
Okay. Thank you for your time. I will try to find a way. I will give an update 🙂
👍 1