shared-hn-android-ios-backend icon indicating copy to clipboard operation
shared-hn-android-ios-backend copied to clipboard

A sample of Android app, iOs app and backend that share some common code via Kotlin Multiplatform

Shared code between Android, iOS and Backend

A sample of Android app, iOs app, and backend that share some common code via Kotlin Multiplatform.

There are two branches:

This sample project is used as reference during my talks, to show how to introduce Kotlin Multiplatform into an existing project:

Repo Structure

hn-foundation

This folder contains the Kotlin Multiplatform library that it's shared between Android, iOs, and the Backend. For Android and the backend, the library is distributed using a local Maven repository. For iOs instead, the library is distributed using two CocoaPod repositories hosted on GitHub:

Publish artifacts for Android and Backend

./gradlew publishToMavenLocal

Publish Debug iOS Framework

./gradlew publishDevFramework

Publish Release iOS Framework

./gradlew publishFramework

N.B. if you want to publish to a different CocoaPod repo, you must have a folder organized like that (where the hn-foundation-cocoa is the repo that contains the framework):

.
├── hn-foundation-cocoa
└── shared-hn-android-ios-backend
    ├── hn-android-client
    ├── hn-backend
    ├── hn-foundation
    └── hn-ios-client

If you change the location, remember to customize the path declared in the task on the build.gradle.kts file

hn-backend

The folder contains a backend written with Ktor. After publishing the artifacts to the local Maven repository you can start the backend on your machine.

hn-android-client

Thet folder contains the Android client. After publishing the artifacts to the local Maven repository and after starting the backend, you can try the android app. Remember to change the base address of the backend here

hn-ios-client

The project contains the iOS client. You should be able to try the iOs app as is since I've published the Pods. Of course, you can create your CocoaPod repository and try yourself the publishing process. Remember to change the base address of the backend here.