When I’m trying to build this sample from Xcode <h...
# kotlin-native
r
When I’m trying to build this sample from Xcode https://github.com/JetBrains/kotlin-native/tree/master/samples/cocoapods I’m getting an error. Do you have an idea what am i do wrong?
Also I tried another libraries. And if a pod has been written in Swift (Alamofire for example) I can’t see any API of the library in Kotlin (iosMain). If a pod uses ObjC then it doesn’t compile.
a
Hello, @Rostislav Utrobin! There is an issue with Xcode 11.4 and Kotlin 1.3.7* versions compatibility. To workaround it, we recommend to add this dependency to your commonMain source set.
r
Thanks for response:) But it doesn’t work for me. It fails with:
a
Hmm, this one seems to be legit as there is no such library for android on the Bintray. Can you change the dependency definition like that? Just to avoid exporting this to Android source set dependency list.
Copy code
kotlin {
    targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
        compilations.all {
            dependencies {
                implementation("org.jetbrains.kotlin.native.xcode:kotlin-native-xcode-11-4-workaround:1.3.72.0")
            }
        }
    }
}
r
I did, but still have the same issue
a
With the same result? Have you disabled the dependency in a
commonMain
block?
r
Yeah the same result. I removed
implementation("workaround..")
from
commonMain
and added to
compilations.all
a
Okay maybe something else is wrong here. I just want to say,
Targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget>
this line must prohibit setting this dependency for any android target. Can you post the details from the error log, please?
r
I tried one more time and it works! Maybe I did something wrong last time. Thank you so much for your help. Could you explain one more question? I tried to use https://github.com/lyft/Kronos and I don’t see any API in iosMain. But when I tried AFNetworking it works well. The only difference I see is the different languages of the pods. AFNetworking uses Objc, Kronos uses Swift.
Oh and also Kronos is full of static API. Might it be a reason?
a
I think the main reason here should be the language difference. K/N provides interoperability with Objective-C, not Swift. I’ve seen that some of this library functions are annotated with
@objc
, but I’m not sure it’s enough to use it.
r
Got it. Thank you for your help 🙂
😎 1