I'm unable to resolve `kotlin.native.concurrent.fr...
# kotlin-native
m
I'm unable to resolve
kotlin.native.concurrent.freeze()
. Can anyone tell me what gradle imports I need? Cannot find it online...
a
It should be imported with the Kotlin stdlib. Could you please share, what’s going wrong in your case?
m
We have a fairly complex setup to create a SDK for both Android and iOS. The common import is including
org.jetbrains.kotlin:kotlin-stdlib-common:1.3.60
I also added
org.jetbrains.kotlin:kotlin-stdlib:1.3.60
, but no success either
a
Please share the Gradle script, at least the dependencies part.
m
s
Are you trying to call it in common code? It only exists in native. You can create an expect actual declaration in common and have the Java/Android version do nothing if you need to call it in common code.
a
One more thing - are you trying to import
freeze()
in the
iosMain
sourceSet? It seems like the IDE can interpret it as a common code. If so, it should not be a problem - on the compilation stage everything should be resolved correctly.
m
I am indeed trying to import it in iosMain, but tried commonMain as well. No luck yet
Android Studio is already marking
native
red in the statement
import kotlin.native.concurrent
a
It has to be imported in the source set, that will be directly associated with the native target(
iosX64Main, iosArm64Main
in your case). Otherwise, the IDE will be unable to resolve it. But, maybe, the compiler itself will be smart enough to resolve the import in the iosMain. One can give it a try, at least.
m
added it there as well: doesn't help 😞
iosX64Main
and
iosArm64Main
depend on
iosMain
, and that worked out so far
a
You mean, you were possible to import native-specific things? This seems interesting.
m
Even weirder: I have another source file in the same sourceset (
iosMain
) that imports
kotlin.native.concurrent.ThreadLocal
and that does not have any issue at all...
🙀 1
a
m
☝️ That works...
I've no clue what it does or what kind of voodoo is going on there, but I have no more unresolved imports
🎉 2