Hi all, i contact you because i try to integrate a...
# multiplatform
j
Hi all, i contact you because i try to integrate an iOS native librairie inside a KMP projet. i use cocoapods to manage the dependencies. it works until i tried to import the library i don’t find the object. if u can help to find why ? and if it’s the best way. Thanks 🙂 A context to understand the structure Swift UI / Jet Pack compose -> KMP shared code (store/usecase) -> API (expect/actual) to use the native part. some code : build.gradle
Copy code
iosTarget("ios") { }
cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        ios.deploymentTarget = "14.1"
        frameworkName = "shared"
        podfile = project.file("../iosApp/Podfile")
        framework {
            isStatic = false
            transitiveExport = true
        }
        pod ("AlgoliaSearchClient")

    }
actual in iOS main:
Copy code
import cocoapods.AlgoliaSearchClient.*

actual interface SearchApi {

    actual fun search(words: String): List<Training> {
        val search = ClientSearch()
        return listOf(Training(id = "1", name = "name1"), Training(id = "2", name = "name2"))
    }
}
v
Hi Julien, The problem is that AlgoliaSearchClient is a pure Swift library and does not provide bridging to Objective-C. Kotlin supports C and Objective-C interop as of now, so to call Swift code from Kotlin it has to provide @objc attributes. Unfortunately, in your case pod dependency will not work out of the box and some manual work has to be done. You can fork the library you want to use, add @objc attributes to the APIs you’d like to use, publish the new library as a private pod and use it as a dependency.
j
oh ok thanks for the feedback 🙂 i never found this in the documentation.