Hi,
I am iOS dev and new to Multiplatform.
I am trying to create Service layer (http requests, models and business logic) in common code which can be used between iOS and Android. I am using IntelliJ IDE.
To make http call I am using ktor(I have installed ktor plugin). Unfortunately, I am getting very basic errors and not able to proceed further. Any help would be great.
Error:
Unresolved reference: io
Gradle:
sourceSets {
commonMain {
dependencies {
implementation kotlin(‘stdlib-common’)
implementation “io.ktor:ktor-client:1.0.0”
implementation “org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.0.1"
}
}
}
A couple of things.
1. If you want to build to both Android and IOS you’ll need to register them as targets in your gradle build and add the platform-specific versions of your dependencies into each of your targets.
2. I don’t think you can call suspend functions directly from Swift/ObjectiveC, so you may need to make a blocking version of
getTodos()
for the iOS version
b
Bhattachar
09/20/2019, 6:03 PM
Thanks for response. I have basic issues with import.
Unresolved reference: io
Error - build.gradle: Failed to resolve: io.ktor:ktor-client-core:1.3.50
e
Evan R.
09/20/2019, 7:18 PM
The most recent version of that package is 1.2.4. Try changing it to