https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Andrey Makovskiy

06/03/2019, 5:43 PM
Error message when compiling iOS framework: Unresolved reference: atomicfu. Jvm library compiles and works. Can anybody help?
k

kpgalligan

06/03/2019, 5:52 PM
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

Andrey Makovskiy

06/03/2019, 5:53 PM
I tried but from iosMain it is not visible too
k

kpgalligan

06/03/2019, 5:56 PM
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

Andrey Makovskiy

06/03/2019, 5:58 PM
I need synchronization and AtomicReference
in common code
synchronized is deprecated for common 😞
there is no volatile for common
k

kpgalligan

06/03/2019, 6:00 PM
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

Andrey Makovskiy

06/03/2019, 6:03 PM
I developing multiplatform kotlin library for Android and iOS
This library also requires threading inside
k

kpgalligan

06/03/2019, 6:04 PM
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

Andrey Makovskiy

06/03/2019, 6:19 PM
OK, thanks. I see that is it available in kotlin/native so I can implement it using expected/actual classes
3 Views