02/23/2018, 10:18 PM
I am creating app in Swift which uses my Kotlin compiled Framework. It works great, but I have Objective-C framework which I would like to use in my Swift and Kotlin code. In my
I have interop task which creates bindings. But from this point i am lost. I tried to copy .kt file from binding into my
project which looks good and compiles. until I try to use code from this file. I got an arror about wrong architecture (even though I am pretty sure i got target iphone_sim everywhere) so I am probably doing it in a wrong way. I am new to gradle and kotlin which does not help either 🙂 So can someone point me how to use "objc-framework" in kotlin code which is afterwards compiled into objc framework ?


02/24/2018, 7:18 AM
if your code is OSS, please share link to it. Generally, for interop you shall create .def file which contains headers you want to use and linker arguments to link with the framework, compile it to the .klib and link your code with this .klib. See for details on interop functioning.


02/24/2018, 8:41 AM
Unfortunately my code is not OSS (if nothing helps, I can create minimal working example). I read that document several times but i am still not sure how to do it. I guess I am not linking the library. The bindings .kt are just for the IDE? here is my build.gradle for common ios
apply plugin: 'konan'

buildscript {
	repositories {
		maven {
        	url "<>"
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:+"

konan.targets = ['iphone_sim']

konanArtifacts {

    def productsDir = new File("/Users/dominik/prace/ios/kotlin-multiplatform/ios/Frameworks")

    interop("libs") {
        defFile "src/main/c_interop/libs.def"

        compilerOpts "-F${productsDir}"
        linkerOpts "-F${productsDir}"

        includeDirs new File(".").getAbsolutePath()

    framework('ComapLike', targets: ['iphone_sim']) {
        srcDir 'src/main/kotlin'

        enableMultiplatform true
        enableDebug false



dependencies {
    expectedBy project(':common')
When added
libraries {
            artifact "libs"
part of my gradle i got following build error
ld: framework not found TestFramework
which is weird, the TestFramework is the one from
from which I successfully created klib in
step. So i dont know why it is trying to link this one instead of
Ok got it 🙂 I added Linker flags