leandro
11/07/2022, 7:50 PMNSURLSession
to ktor’s HttpClient
? something like
engine {
val config = NSURLSessionConfiguration.defaultSessionConfiguration()
val session = NSURLSession.sessionWithConfiguration(config)
usePreconfiguredSession(session)
}
It’s hard to debug the real issue but it basically does not work. The iOS app does not crash, but no network call is made.ayodele
11/08/2022, 7:23 AMDarwin
engine as a dependency in your iosMain you won't need to pass an engine as ktor will automatically detect it.leandro
11/08/2022, 7:59 AMactual class WikipediaHttpClientProvider @Inject constructor(
client: NSURLSession,
json: Json,
) {
actual val value: WikipediaHttpClient = HttpClient(Darwin) {
defaultRequest(getDefaultRequest())
engine {
usePreconfiguredSession(client)
}
install(ContentNegotiation) {
json(json)
}
}
}
ayodele
11/08/2022, 8:05 AMleandro
11/08/2022, 8:34 AMapply plugin: 'org.jetbrains.kotlin.multiplatform'
kotlin {
iosX64()
iosArm64()
iosSimulatorArm64()
sourceSets {
iosMain {
dependsOn commonMain
dependencies {
api 'io.ktor:ktor-client-darwin:2.1.2'
}
iosX64Main.dependsOn it
iosArm64Main.dependsOn it
iosSimulatorArm64Main.dependsOn it
}
}
ayodele
11/08/2022, 8:40 AMcommonMain
don't need pass in an engine. Just calling HttpClient()
will automatically pick the engine for different platforms as long as the engine dependency is in the classpath.
So basically you don't have actual/expect the client yourself.leandro
11/08/2022, 8:59 AMRustam Siniukov
11/08/2022, 9:36 AMleandro
11/08/2022, 9:42 AMRustam Siniukov
11/08/2022, 10:00 AMleandro
11/08/2022, 10:01 AM