Error message when compiling iOS framework: Unreso...
# multiplatform
a
Error message when compiling iOS framework: Unresolved reference: atomicfu. Jvm library compiles and works. Can anybody help?
k
I assume you’ll need to add the library dependency. I’m also not sure the atomics will do what you expect in native
a
I tried but from iosMain it is not visible too
k
id ‘kotlinx-atomicfu’ is not native capable. You need to add atomic-fu directly as a dependency. That’s what the screenshot I shared is saying. Also, although this “compiles”, it doesn’t actually do anything atomically, if you’re hoping to interact with data from multiple threads: https://github.com/Kotlin/kotlinx.atomicfu/blob/master/atomicfu/src/nativeMain/kotlin/kotlinx/atomicfu/AtomicFU.kt
To take a step back, I guess, what are you trying to do?
a
I need synchronization and AtomicReference
in common code
synchronized is deprecated for common 😞
there is no volatile for common
k
The sample app is old, but I wrote this: https://github.com/touchlab/Stately
I feel like you should also understand how native threads work better, but I may be assuming things about your experience level with native.
a
I developing multiplatform kotlin library for Android and iOS
This library also requires threading inside
k
Have you done any threading with native?
It’s not just atomics and synchronization. State is very different
I also have some blog posts
The 3rd one, explaining how all that works in Multiplatform, is pending a new version of Stately (which I’m currently working on)
a
OK, thanks. I see that is it available in kotlin/native so I can implement it using expected/actual classes