https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
z

ZabGo

05/01/2020, 2:10 PM
Hello, I would like to add a third party library to my kotlin multiplatform project. I managed to add it for Android but I am kind of stuck for iOS. It's building without any error but I cannot access it from kotlin. I can see it in my external libraries with the binaries files but there are no headers. I can access org.sample though but it’s empty. So I thought that the issue could come from the missing headers but after several tries I cannot figure it out.  If you have any ideas, that would be great!!! Thanks for your help Here my config: build.gradle
Copy code
iosX64("ios") {
  binaries {
    binaries {
      framework('Shared')
    }
  }

  compilations.main{
    cinterops{
      myCinterop{
        packageName "org.sample"
        defFile project.file("$projectDir/myDefFile.def")
        includeDirs("$projectDir/lib/ios/MyLibraryName.framework/Headers/Lmi")
      }
    }
  }
}
myDefFile.def
Copy code
language = Objective-C
staticLibraries= binaryFile1.a binaryFile2.a binaryFile3.a
libraryPaths = /path/to/binaries/
linkerOpts= -F/path/to/binaries/ -framework MyLibraryName
k

Kris Wong

05/01/2020, 2:36 PM
the bindings are generated from the headers
z

ZabGo

05/01/2020, 2:52 PM
I thought that
includeDirs("$projectDir/lib/ios/MyLibraryName.framework/Headers/Lmi")
would include the headers. It's not the case then, isn't it?
k

Kris Wong

05/01/2020, 3:36 PM
you need to add headers and headerFilter to your def file
includeDirs
just tells it where to find headers
z

ZabGo

05/01/2020, 3:49 PM
ok I thought includeDirs was a shortcut to add all the headers at once. I think that a little bash script will be needed to add them to the def file then ;) Sorry if my questions sound dumb, not really used to deal with all this yet
k

Kris Wong

05/01/2020, 3:56 PM
it parses them recursively, if that helps
hence the headerFilter
z

ZabGo

05/01/2020, 4:14 PM
Ok I see. it looks like it's working. I have some errors but it's not related to kmp I think. Thanks for your help!
🍻 1
3 Views