
Let's Run our first Hello World Program :)Ĭreate a file Sample.kt in shared/kotlin folder and add,įun sayHelloWorld(): String = "Hello World"

In the android app I will implement it as a library of Android, We have added iOS and android using,Ĭontains the dependency for the individual projects as specified above. In this, we add the device configuration where I can run the apps to test. We added the plugin library just so that it can be imported into the Android project Here, we have added a plugin for multiplatform and library. Group = JavaBasePlugin.VERIFICATION_GROUPĭescription = "Runs iOS tests on a simulator"ĭef binary = .getTest('DEBUG').outputFileĬommandLine 'xcrun', 'simctl', 'spawn', device, binary.absolutePath make sure all Gradle infrastructure exists (gradle.wrapper, gradlew).ĭef buildType = project.findProperty('') ?: 'DEBUG'ĭef target = project.findProperty('kotlin.target') ?: 'ios'ĭependsOn kotlin.targets."$target".binaries.getFramework(buildType).linkTaskĭef srcFile = kotlin.targets."$target".binaries.getFramework(buildType).outputFileĭef targetDir = getProperty('')ĭef device = project.findProperty("iosDevice")?.toString() ?: "iPhone X"ĭependsOn .getTest('DEBUG').linkTaskName Before opening the project from iosApp directory in Xcode,

Xcode runs this task itself during its build process. This task attaches native framework built from ios module to Xcode project Implementation kotlin('test-annotations-common') Switch here to iosArm64 (or iosArm32) to build library for iPhone deviceįinal def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \ We will replace with the following,Īpply plugin: 'kotlin-android-extensions' So, now let's do some coding in the multiplatform projects. Is the android project we created using Android Studio and pasted it here. To summarise, Kotlin Multiplatform is a way to share code between different platforms. Kotlin Multiplatform says that, it will take care of the buisness logic and we just need to take care of the UI.

Kotlin Multiplatform is a kotlin language feature that allows us to run Kotlin in JavaScript, iOS, and native desktop applications and hence develop apps using Kotlin. So, in place of writing two apps, Kotlin Multiplatform provides a way to share common business logic and build apps for different platforms using Kotlin. We might have design changes but more or less we have the same core logic for the apps. When we build an app for our startup, we write iOS or Android apps most commonly. How to set up your Kotlin Multiplatform project? How has Kotlin been working out for you in your Android projects? What if I tell you Kotlin can be used to build multi-platform apps and to be very clear I am not talking about just iOS and Android but even JavaScript apps.
