{"id":15007157,"url":"https://github.com/wojta/hello-kotlin-multiplatform","last_synced_at":"2025-09-24T00:32:02.533Z","repository":{"id":52497102,"uuid":"48368052","full_name":"wojta/hello-kotlin-multiplatform","owner":"wojta","description":"Multiplatform Kotlin Hello World (Android/iOS/Java/JavaScript/Native)","archived":false,"fork":false,"pushed_at":"2024-07-12T08:56:24.000Z","size":7376,"stargazers_count":76,"open_issues_count":1,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-08T04:23:07.871Z","etag":null,"topics":["android","console-application","frontend-javascript","ios-app","ios-swift","jvm","kotlin","kotlin-android","kotlin-js","kotlin-multiplatform","linux-app","node-javascript","platform-independent"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wojta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-21T11:24:49.000Z","updated_at":"2024-12-26T10:26:40.000Z","dependencies_parsed_at":"2024-09-28T16:00:48.253Z","dependency_job_id":"74b4277e-0640-4c64-bddc-2c027fdfb5c1","html_url":"https://github.com/wojta/hello-kotlin-multiplatform","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wojta%2Fhello-kotlin-multiplatform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wojta%2Fhello-kotlin-multiplatform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wojta%2Fhello-kotlin-multiplatform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wojta%2Fhello-kotlin-multiplatform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wojta","download_url":"https://codeload.github.com/wojta/hello-kotlin-multiplatform/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234017089,"owners_count":18766450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","console-application","frontend-javascript","ios-app","ios-swift","jvm","kotlin","kotlin-android","kotlin-js","kotlin-multiplatform","linux-app","node-javascript","platform-independent"],"created_at":"2024-09-24T19:04:51.015Z","updated_at":"2025-09-24T00:31:57.124Z","avatar_url":"https://github.com/wojta.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/wojta/hello-kotlin-multiplatform/tree/master.svg?style=svg)](https://circleci.com/gh/wojta/hello-kotlin-multiplatform/tree/master)\n\n**KOTLIN 2.0.0**\n\n# Multiplatform Kotlin Hello World\n\nThis project demonstrates sharing runtime independent code between different Kotlin's runtimes ([Java](http://www.java.com)/[Android](https://developer.android.com/index.html)/[JavaScript](https://en.wikipedia.org/wiki/JavaScript)). It uses [Gradle](http://gradle.org/) build engine.\n\nIt uses new support for multiplatform modules with plugin `kotlin-multiplatform`.\n* [Kotlin multiplatform overview](https://kotlinlang.org/docs/multiplatform.html) \n\nThis example uses now Kotlin Multiplatform as is in Kotlin 2.0.0.\n\n### Deprecated implementations\nOlder implementation with `kotlin-multiplatform` plugin and various hacks was moved to [old-kotlin-1.2](https://github.com/wojta/hello-kotlin/tree/old-kotlin-1.2) branch.\n\nMore older implementation that didn't use `kotlin-multiplatform` plugin and various hacks was moved to [old-multiplatform](https://github.com/wojta/hello-kotlin/tree/old-platform-modules) branch.\n\nOldest implementation that used various hacks was moved to [old-multiplatform](https://github.com/wojta/hello-kotlin/tree/old-multiplatform) branch.\n\n## What is Kotlin?\n[Kotlin](http://kotlinlang.org) is a programming language developed by [Jetbrains](https://www.jetbrains.com/). It's fully compatibile with [Java](http://www.java.com) runtimes and also there is support for [JavaScript](https://en.wikipedia.org/wiki/JavaScript) transpilation. Experimental version of [Kotlin/Native](https://kotlinlang.org/docs/reference/native-overview.html) has goal to also build fully native apps for iOS, Linux, Windows and possibly other platforms.\n\n## What is it doing?\n* writes Hello Kotlin!\n* calculates first 1000 prime numbers (this part is shared between runtimes) and prints them\n\n\n## Structure\nIt's the Gradle multiple modules project. \n\n* ``hello_android_app`` - Android application module, it's compiled to DEX bytecode, it produces APK file upon build\n* ``hello_ios_app`` - Swift application for iOS, XCode project \n* ``hello_js_browser_app`` - application transpiled for frontend JavaScript, packed in [WebPack](https://webpack.js.org/), it's only statically served by Node.js\n* ``hello_js_node_app`` - console application transpiled to Node.js JavaScript \n* ``hello_jvm_app`` - console application compiled to Java bytecode for JVM, produces JAR that can be executed by eg. Oracle JVM\n* ``hello_console_app`` - console application (Linux x64 \u0026 arm64)\n* ``hello_shared`` - multiplatform library project, with shared and platform specific code\n    * ``commonMain`` - shared Kotlin source code, platform independent code\n    * ``commonTest`` - shared tests, platform independent tests\n    * ``jsMain`` - JavaScript runtimes platform dependent code\n    * ``jsTest`` - JavaScript runtimes specific tests\n    * ``jvmMain`` - Java runtime platform dependent code\n    * ``jvmTest`` - Java runtime specific tests \n    * ``androidMain`` - Android runtime platform dependent code\n    * ``androidTest`` - Android runtime specific tests\n\n[Modules dependency](.images/diagram_simple.png)\n\n## Platform implementation specifics\n* prime number calculation is platform independent, single code shared for all platforms \n* text output on screen is platform dependent \n    * **Android** - it's done by adding with TextView to layout\n    * **iOS** - stores lines in `ArrayList`, then it passes it through `Flow` and uses [SKIE](https://skie.touchlab.co/features/flows-in-swiftui) `Observing` on iOS Swift app end\n    * **Frontend JavaScript** - it adds element in DOM of HTML page\n    * **Native Console** - uses POSIX `printf`\n    * **Node.js JavaScript** - uses `console.log()`\n    * **JVM** -  uses `System.out.println()`\n\n_Note: Ordinary console output can be done by `println()` function from Kotlin Standard Library. It's only for demonstration purposes._\n\n[Implementation in modules](.images/diagram_detailed.png)\n\n## Building and running the demo\nIt was checked under Fedora Workstation (Linux), probably there won't be any problems with most Unix-like environments.\n\n### Android application \nYou can use Android Studio to run the application. To build from command line, you can use\n\n    $ ./gradlew hello_android_app:build\n\nand APK file is located in your ``build/outputs/apk`` directory.\n\n![Hello Android](.images/hello_android.png)\n\n### iOS application\n\nIt's in directory `hello_ios_app`. It's XCode project with SwiftUI application. `hello_shared` uses [SKIE](https://skie.touchlab.co/intro) library \nto improve interoperability. \n\n![Hello iOS](.images/hello_ios.png)\n\n### JVM console application\n\n    $ ./gradlew hello_jvm_app:build\n\nYou can than run the JAR file using `java -jar hello_jvm_app.jar` command from ``build/libs`` directory. \n\n![Hello JVM](.images/hello_jvm.png)\n\n### Frontend JavaScript application\n\n    $ ./gradlew hello_js_browser_app:build\n\nWebpack allows to host site directly from Gradle by\n\n    # ./gradlew hello_js_browser_app:run \n    \nIt will run locally on [http://localhost:8088/](http://localhost:8088/). \n\n![Hello JavaScript Browser](.images/hello_js_browser.png)\n\n### Node.js console application\n\n    $ ./gradlew hello_js_node_app:build\n\nYou can execute it in `hello_js_node_app/build/productionLibrary` directory by executing:\n\n    $ node .\n\n![Hello JavaScript Node.js](.images/hello_js_node.png)\n\n\n### Native console application\n\nYou can execute it with Gradle, if platform is not supported, the task will be skipped \n(like trying to run Linux app under MacOS X).\n\n```\n   $ ./gradlew hello_console_app:runHello_console_appDebugExecutableLinuxX64\n```\n\nYou can find .kexe binary in the build directory and execute it from there as well.\n\n```\n   $ cd hello_console_app/build/bin/macosArm64/hello_console_appDebugExecutable\n   $ ./hello_console_app.kexe\n```\n\n![Hello MacOS](.images/hello_macos.png)\n    \n### to see all build options    \n    \n    $ ./gradlew tasks --all\n    \n## License\nDo whathever you want with this. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwojta%2Fhello-kotlin-multiplatform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwojta%2Fhello-kotlin-multiplatform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwojta%2Fhello-kotlin-multiplatform/lists"}