Hi everyone :wave: I am trying to add `DataDog` li...
# multiplatform
h
Hi everyone 👋 I am trying to add
DataDog
library in iosMain part of the KMM project. But Somehow I can not import the library into Kotlin file. Here is the ticket that I opened yesterday. https://youtrack.jetbrains.com/issue/KT-55687/Can-not-add-DataDog-Dependency-via-CocoaPods-in-Kotlin-Multiplatform-Mobile-Project I really appreciate if you guide me. Thanks.
k
Have you tried installing the pod?
h
In build gradle you don't have to call command
pod install
. But you have to sync gradle file since my intention is to use in KMM project.
And I installed the pod in a Xcode project and it was working fine.
d
If DataDog is a pure Swift library, this could be a reason why the interop isn't working as expected.
I see the SDK offers some explicit ObjC compatibility feature
You'll need to be using this for Kotlin/Native interop
h
Hi Chris, Sorry but I couldn't understand your last message. What should I do with Kotlin/Native interop? Do I have to write some wrapper class in Kotlin?
d
It's notable that CocoaPods hosts both a DataDogSDK and a DataDogObjC
...suggesting that the non-ObjC one is pure Swift ABI - Kotlin Native won't be able to interop with this
try using the DataDogObjC one.
h
Yes. I used the ObjC one but then I couldn't import the library.
Ok We have finally managed to make it work using the 'proxy'(
DDLog
) framework. Because DataDogObjCSDK we giving error when doing a gradle sync This is the cocoapods configuration:
Copy code
cocoapods {
        summary = "Common library for mobile project"
        homepage = ""
        version = "1.0"
        ios.deploymentTarget = "11.0"
        framework {
            baseName = "MultiPlatformLibrary"
            linkerOpts.add("-lsqlite3")
            isStatic = false
            transitiveExport = true
            export(Deps.kermit)
            export(Deps.Moko.mvvm_api)
            export(Deps.Moko.resources)
        }
        /*
        pod("DDLogg") {
            moduleName = "DDBridge"
            source = git("<https://github.com/aneeshzed/DDLogg.git>") {
                tag = "0.1.7"
            }
        }*/
        pod("DatadogSDKObjc") {
            version = "~> 1.14"
            moduleName = "Datadog"
        }
        pod("DatadogSDK") {
            version = "~> 1.14"
            moduleName = "DatadogObjc"
        }
        xcodeConfigurationToNativeBuildType["Pilot"] = org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG
    }
And this is the error that we get:
m
I was also getting same error , solved by this:
Copy code
tasks.named<org.jetbrains.kotlin.gradle.tasks.DefFileTask>("generateDefDatadogObjc").configure {
    doLast {
        outputFile.writeText("""
            language = Objective-C
            modules = Datadog DatadogObjc
        """)
    }
}
Ref: https://youtrack.jetbrains.com/issue/KT-44724
s
@Mukesh Where did you add this code?
m
@Sonny at the end of your module’s gradle file
202 Views