iOS Swift interop question: ``` Uncaught Kotlin ex...
# kotlin-native
d
iOS Swift interop question:
Copy code
Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared kotlin.collections.HashMap@8015aa08 from other thread
How do I go about avoiding this? Can I simply make the HashMap in question shared? Immutable? Freeze it? Throw a bunch of
DispatchQueue.main.async {  }
wrappers everywhere? The stack trace goes from Kotlin to Swift and back to Kotlin at least once, likely more than once. The thread that is crashing is
com.google.firebase.auth.globalWorkQueue
d
.freeze()
it.
1
k
freeze, or if you super need a shared map https://github.com/touchlab/Stately
d
silly question, can't find docs, what do my gradle and import line look like to make
.freeze()
available?
k
freeze isn’t available in common code. Only native. Also in Stately: https://github.com/touchlab/Stately/blob/master/stately/src/commonMain/kotlin/co/touchlab/stately/Helpers.kt That lets you “freeze” from common code. Will do nothing on other platforms
d
interesting... can i just
expect fun freeze(x: Any): Any
and
actual fun freeze(x: Any) = x.freeze()
?
oh
.freeze()
does not exist on the android side i see
k
The android side should just so nothing in it’s freeze actual
p