Hello. Maybe someone faced with Ktor Darwin comple...
# multiplatform
i
Hello. Maybe someone faced with Ktor Darwin completionHandler issue? When I cast NSURLSessionAuth to Int, it builds on Android normally, but not on iOS. If I leave it as is, it won't build at all. Under the hood this variable is NSUInteger. And NSUInteger == ULong.
Copy code
HttpClient(Darwin) {
        engine {
            handleChallenge { session, task, challenge, completionHandler ->
                if (protectionSpace.authenticationMethod == NSURLAuthenticationMethodClientCertificate) {

                    if (identity != null) {
                        completionHandler(
                            NSURLSessionAuthChallengeUseCredential.toInt(),
                            credential
                        )
                    } else {
                        completionHandler(
                            NSURLSessionAuthChallengePerformDefaultHandling.toInt(),
                            null
                        )
                    }
                } else {
                    completionHandler(
                        NSURLSessionAuthChallengePerformDefaultHandling.toInt(),
                        null
                    )
                }

        }
    }
}
f
That’s a false positive
Don’t try to convert to the expect type
i
Android Studio can't build the apk. Build is crashed
c
How could you use the Darwin engine on Android? It's only for native targets. https://ktor.io/docs/client-engines.html#platforms
i
I used it For IOS
c
Android Studio can't build the apk. Build is crashed
So how is that related to your question then?
i
Because compiler do the task (compileIosMainKotlinMetadata) when we build APK. And compiler can't prepare
metadata.klib
file because can't understand the type of the variables
c
Can you share your Gradle build files? There seems to be something off with your setup.
i
There are a lot of gradle files that is why it's hard to share. But It looks like Koin + KSP effects somehow or Common variables which I use in my Darwin class. I created small project and I didn't face with such issue
👍🏻 1