https://kotlinlang.org logo
Title
f

Filip Wiesner

01/28/2023, 7:02 PM
Getting following error when building iOS shared module with molecule dependency
e: Module "app.cash.molecule:molecule-runtime (app.cash.molecule:molecule-runtime-iosarm64)" has a reference to symbol androidx.compose.runtime/Composition.setContent|-2259719813581705387[0]. Neither the module itself nor its dependencies contain such declaration.
What am I doing wrong? I am using Kotlin 1.8.0.
This could happen if the required dependency is missing in the project. Or if there is a dependency of "app.cash.molecule:molecule-runtime (app.cash.molecule:molecule-runtime-iosarm64)" that has a different version in the project than the version that "app.cash.molecule:molecule-runtime (app.cash.molecule:molecule-runtime-iosarm64): 0.7.0" was initially compiled with. Please check that the project configuration is correct and has consistent versions of all required dependencies.

The list of "app.cash.molecule:molecule-runtime (app.cash.molecule:molecule-runtime-iosarm64): 0.7.0" dependencies that may lead to conflicts:
1. "stdlib: 1.8.0" (was initially compiled with "stdlib: 1.6.21")
2. "org.jetbrains.kotlin.native.platform.CoreFoundation: 1.8.0" (was initially compiled with "org.jetbrains.kotlin.native.platform.CoreFoundation: 1.6.21")
3. "org.jetbrains.kotlin.native.platform.darwin: 1.8.0" (was initially compiled with "org.jetbrains.kotlin.native.platform.darwin: 1.6.21")
4. "org.jetbrains.kotlin.native.platform.posix: 1.8.0" (was initially compiled with "org.jetbrains.kotlin.native.platform.posix: 1.6.21")
5. "org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-iosarm64): 0.18.5" (was initially compiled with "org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-iosarm64): 0.17.3")
6. "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-iosarm64): 1.6.4" (was initially compiled with "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-iosarm64): 1.6.1")
j

jw

01/28/2023, 7:21 PM
f

Filip Wiesner

01/28/2023, 7:28 PM
Nope, will try :thank-you:
Thank you, that definitely helped. But now I see this error (not sure if it's related)
> Task :sharedMobile:linkDebugFrameworkIosArm64 FAILED
e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors

The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
Undefined symbols for architecture arm64:
  "_kfun:(...path to @Composable function...)", referenced from:

  ... more "_objc2kotlin_kfun" stuff

ld: symbol(s) not found for architecture arm64
But at least I have different error now after an hour of debugging 😄
s

saket

01/28/2023, 8:14 PM
are your composable functions public?
f

Filip Wiesner

01/28/2023, 8:18 PM
yes
s

saket

01/28/2023, 8:20 PM
what happens if you make them internal?
k

kevin.cianfarini

01/28/2023, 8:28 PM
If its the above, its a bug in the compose compiler in (I think?) IOS source sets
f

Filip Wiesner

01/28/2023, 8:29 PM
huh, that works 🤔 So the workaround is to expose only the
StateFlow
and keep the
@Comcposable
functions internal I guess... 😕
Thank you Saket. You saved me a few hours of debugging 😌
k

kevin.cianfarini

01/28/2023, 8:30 PM
We currently just have an abstract class that declares our molecule stuff as internal. Will move to an interface with a public function when thats resolved
p

Pablichjenkov

01/29/2023, 2:15 AM
For more information on the Composable internal issue. Notice the problem is only in the last module that builds the iOS target. You can have libraries that expose them as public. https://github.com/JetBrains/compose-jb/issues/2346