https://kotlinlang.org logo
#webassembly
Title
# webassembly
j

John O'Reilly

12/07/2023, 4:58 PM
Up to now I've used Ktor
3.0.0-wasm1
version in isolated module but trying it now in common code in a KMP project.....it seems to mostly work but on iOS I'm getting following....I have added
atomicfu
in dependencies but perhaps might be using wrong version (also using coroutines
1.8.0-RC
)
Copy code
w: skipping /Users/joreilly/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/atomicfu-iossimulatorarm64/0.23.1/577e14084dac4dbadcaf86db01f359b4939f5d5a/atomicfu-cinterop-interop.klib. The library versions don't match. Expected '0.22.0-wasm2', found 'unspecified'
b

bashor

12/07/2023, 5:05 PM
cc @Igor Yakovlev
@John O'Reilly please try to specify explicitly atomicfu as dependency, as workaround
j

John O'Reilly

12/07/2023, 5:08 PM
Yeah, I have that but still getting that error.....perhaps using wrong version.....what version should I have?
have this right now
Copy code
implementation("org.jetbrains.kotlinx:atomicfu:0.23.1")
i

Igor Yakovlev

12/07/2023, 5:35 PM
I made a simple project and for me seems everything works well. Could you please to send me a small repro to check it on my side? (please notice, that ktor you use is not published in the main channel yet and its highly experimental).
j

John O'Reilly

12/07/2023, 5:35 PM
will do, is that the version of atomicfu you're using btw?
could you also share
commonMain
dependencies you have there?
i

Igor Yakovlev

12/07/2023, 5:37 PM
Copy code
val commonMain by getting {
    dependencies {
        implementation("io.ktor:ktor-client-core:3.0.0-wasm1")
        implementation("io.ktor:ktor-client-cio:3.0.0-wasm1")
    }
}

val commonTest by getting {
    dependencies {
        implementation(kotlin("test"))
    }
}
j

John O'Reilly

12/07/2023, 5:38 PM
ok, so you didn't need to specify atomicfu dependency explicitly?
(when using 1.8.0-RC of kotlinx coroutines)
i

Igor Yakovlev

12/07/2023, 5:41 PM
this is a bug with dependency for native targets, which is not connected with wasm or ktor
j

John O'Reilly

12/07/2023, 5:41 PM
I see issue here then if running say (used kmp.jetbrains.com to generate project)
Copy code
./gradlew :composeApp:compileKotlinIosSimulatorArm64
I thought maybe ktor was coming in to picture here due to some dependency it had on atomicfu (given
expected '0.22.0-wasm2'
in error above)
should be able to use https://github.com/joreilly/ClimateTraceKMP to reproduce error
a

Andrey Larionov

12/08/2023, 10:22 AM
@John O'Reilly Hi, did you fix it? I mention about it at KT-64111 issue
j

John O'Reilly

12/08/2023, 10:23 AM
No, not yet
looks like same issue I'm seeing at least
a

Andrey Larionov

12/08/2023, 11:02 AM
@Igor Yakovlev @bashor Hello. I created a simple project and you can test this error. Steps: 1. Go to gist and run a simple local Flask server (pip install flask & pip install flask_cors required) 2. Clone this repo and run any configuration except iOS to be sure that everything works fine a. For Desktop or Web configurations, change 10.0.2.2 to localhost b. I ran Android configuration on Emulator so I needed to use 10.0.2.2 proxy (because localhost provides emulator in this case) 3. Run iOS configuration P.S. Yes, I tried to specify explicitly atomicfu as dependency, but it doesn’t work
i

Igor Yakovlev

12/08/2023, 3:02 PM
I published ktor
3.0.0-wasm2
into experimental repository which is not affected to this issue.
a

Andrey Larionov

12/08/2023, 3:26 PM
Copy code
Could not find io.ktor:ktor-client-core:3.0.0-wasm2
Could not find io.ktor:ktor-client-content-negotiation:3.0.0-wasm2
Could not find io.ktor:ktor-serialization-kotlinx-json:3.0.0-wasm2
j

John O'Reilly

12/08/2023, 5:16 PM
@Igor Yakovlev it looks all right like it's only been published for some artefacts e.g. it's not there for https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental/io/ktor/ktor-client-core/
i

Igor Yakovlev

12/08/2023, 6:45 PM
Yeah…something went wrong. I will republish it soon
👍 1
♥️ 1
j

John O'Reilly

12/08/2023, 7:27 PM
I notice there's a
3.2.0
version there (and have been getting renovate notifications about that version today for various repos)....assume that's a mistake?
a

Andrey Larionov

12/08/2023, 9:27 PM
@John O'Reilly If you use Kotlin/Wasm you should use
:wasm
version everywhere it’s possible I guess if your project includes only Android, iOS and Desktop configurations, you can use the lates available version eg
3.2.0
By the way, you can easily check it by creating a simple project via Kotlin Multiplatform Wizard without a Web configuration
j

John O'Reilly

12/09/2023, 3:11 PM
@Igor Yakovlev I'm seeing all needed
3.0.0-wasm2
ktor dependencies available now, thanks!
1
kodee welcoming 1
👍 1
And confirmed iOS client is building/running now as well.
1
.wasm 1
👍 1
8 Views