I came across an article talking about the concurr...
# multiplatform
r
I came across an article talking about the concurrency model and it talks about freeze(). I tried to run the code but the IDE does not recognise the freeze() method. What am I doing wrong? https://play.kotlinlang.org/hands-on/Kotlin%20Native%20Concurrency/02_Frozen
t
freeze is only available in native source sets (e.g. iosMain)
r
My project is refusing to work with iOS, do you know if I create Kotlin code that “breaks the rules” in some way to do with mutable state, it will crash iOS?
even if I don’t reference those classes in iOS?
t
Hm if you don't reference it in iOS it shouldn't be a problem. Illegal mutable state sharing only results in runtime crashes at the time it's invoked
r
any resources for writing the kotlin code in such a way as to not hit the “rules”?
t
Kevin Galligan's talk on KotlinConf 2019

https://youtu.be/oxQ6e1VeH4M

. I think that codelab you're seeing is a resource from this talk
👍 1
r
I followed some jetbrain tutorial a showing how to make a network request
it worked but when i tried to write my own code to do something similar it worked fine on android but i got errors in iOS
doesn’t help that my iOS knowldesge is zero
t
I don't know much either, thankfully my collegues can help me
What were these errors? Maybe I can help
r
that would be great, give me a sec
06-17 120230.018 💜 VERBOSE HTTP Client - RESPONSE https://gitcdn.link/cdn/KaterinaPetrova/greeting/7d47a42fc8d28820387ac7f4aaf36d69e434adc1/greetings.json failed with exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlin.collections.HashMap@cc0428
t
You're using Ktor?
r
here’s the source code for the shared kotlin code being called from iOS
whats strange is that this all worked at one point
I started adding more kotlin code and tested on android
all worked but whn i tried on iOS i got these errors, even when i stopped refrencing my code and went back to the sample
yes Ktor
i just checked out the sample project from github (my initial project was written manually)
t
Might be a problem with your dependencies
r
hmm, but KMM can use coroutines
and the sample did work
t
Are you using any libraries that the sample doesn't use?
r
i added kotlinx serialisation
I’m going to build my app bit by bit and see when it started to fail
t
Try adding this to commonMain:
Copy code
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core"){
    version {
        strictly("1.5.0-native-mt")
    }
}
r
so commonMain has no depndecy on coroutines
but the androidTest section has implementation(“org.jetbrains.kotlinxkotlinx coroutines test1.5.0”)
the android app has a dependency to:
Copy code
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
t
Try using the mt version
r
but when i add what you suggested to commonMain
Cannot find a version of ‘org.jetbrains.kotlinx:kotlinx-coroutines-core’ that satisfies the version constraints: Dependency path ‘PocKMMandroidAppPocunspecified’ --> ‘org.jetbrains.kotlinxkotlinx coroutines core1.5.0’
t
When using other libraries that also depend on 
kotlinx.coroutines
, such as Ktor, make sure to specify the multithreaded version of 
kotlinx-coroutines
r
where did you get that from?
r
thanks!
t
Did it solve your problem?
r
unfortunately not
but thanks anyway