How to add kotlin native support for an existing swift iOS project?


#1

For example. A brand new Tab-Nav sample from New Project

Previously, when I can use the following build.gradle to compile the main.kt and finally replace the main entry of an Obj-C project.

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
        }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.3.4"
    }
}

apply plugin: "konan"

konan.targets = ["iphone"]

konanArtifacts {
    program('app')
}

But when building from kotlin code to a framework, how to write the build.gradle file?

Pretty new to gradle building system. I want to setup a project like this:

-Xcode Project
-Kotlin native shared logic
-Kotlin native repo
-build.gradle
-build folder

Such that, I can use KN repo to catch up with the latest update, and compile my KN shared logic to iOS framework with the build.gradle setting using the KN repo code base, the outcome will be saved to the build folder.

How to write the build.gradle to make it work? Thanks. :slight_smile:


#2

Just in case someone needs it.

Just include the gradle plugin, and don’t mess up with the version number, it’s not always 3 digits, for instance, sometimes, it’s 0.3.4, but for the current latest version, it’s 0.5 rather than 0.5.0.