A sample project that helps to start building a Mobile Kotlin Multiplatform application

Related tags

Kotlin moko-test
Overview

moko-template
GitHub license kotlin-version

Mobile Kotlin multiplatform project template

A sample project that helps to start building a Mobile Kotlin Multiplatform application. It establishes an architecture optimized for building cross-platform mobile applications through separation of concerns between the UI and business logic.

Table of Contents

Features

  • Kotlin Multiplatform's motto is Don't Repeat Yourself. Share the business logic code written in Kotlin between Android and iOS apps. 100% native UI and performance (shared code compiles into native libraries);
  • Kotlin Gradle DSL – Configure project with flexible Kotlin Gradle DSL;
  • Modular-bazed architecture – Implement app features independently of each other. Inject dependencies into features at compile-time through the use of the Factory class;
  • Parallel build of modules – Feature modules and the domain module don't depend on each other. This provides caching of build artifacts for each module and results in better compilation time;
  • Dependencies definition in buildSrc - Simplify dependency management across modules;
  • Ready to use - Template project includes all moko libraries and supports most common use cases:
    • ViewModels;
    • LiveData;
    • Resource management;
    • Runtime permissions access;
    • Media access;
    • UI lists management from shared code;
    • Network layer generation from OpenAPI.

Modules

Legend

The color describes different modules and the shape - the type of an element (class|interface). legend

Modules scheme

modules scheme This scheme shows the structure of the project:

  • We have two applications that represent the View application layer:
    • android-app written in Kotlin uses Activity and Fragment;
    • ios-app written in Swift uses UIViewController with Storyboards.
  • Both applications depend on mpp-library (Kotlin Multiplatform) that provides access to ViewModel's of each feature through SharedFactory. The library is responsible for setting up connections between the feature and domain modules.
  • mpp-library consists of modules:
    • domain (Kotlin Multiplatform) - contains the domain entities, repositories, server API classes, and DomainFactory that creates instances for all of them;
    • feature (Kotlin Multiplatform). Every feature contains corresponding ViewModel, Factory, models, and interfaces it expects to be injected from the parent module. In this example:
      • config contains an config feature's ViewModel, data store interface and ConfigFactory that create instances of ViewModel;
      • list contains a items list feature's ViewModel, data source interface, list items factory interface, and ListFactory that create instances of ViewModel.

Config module scheme

config module scheme The connections between the feature:config classes and the domain classes implemented in the mpp-library module.

List module scheme

list module scheme The connections between the feature:list classes and the domain classes implemented in the mpp-library module.
SharedFactory.NewsUnitsFactory interface is implemented on both platforms - Android (android-app) and iOS (ios-app).

Screenshots

Android iOS
android-app ios-app
android-app ios-app

How to Run

Android - just open repository root directory in Android Studio and press Run.
iOS - run pod install in directory ios-app. Then open ios-app/ios-app.xcworkspace and press Run on simulator/device.

Project setup

Setup your own ApplicationId

Just like in other native apps
In android-app/build.gradle.kts change org.example.app in the following line:

applicationId = "org.example.app"

In Xcode project settings change Bundle Identifier.

Setup your own project name

Just like in other native apps
In android-app/src/main/res/values/strings.xml change value of app_name.
In Xcode project settings change Display name.

Setup your own app icon

Just like in other native apps
Put your android icon to android-app/src/main/res and setup usage in android-app/src/main/AndroidManifest.xml.
Put your iOS icon to ios-app/src/Assets.xcassets/AppIcon.appiconset.

Create new feature module

Create a file mpp-library/feature/myfeature/build.gradle.kts with the following content:

plugins {
    id("multiplatform-library-convention")
}

Add module to settings.gradle.kts:

include(":mpp-library:feature:myfeature")

Add dependency to module from the mpp-library in mpp-library/build.gradle.kts:

framework {
    ...
    export(projects.mppLibrary.feature.myfeature)
}

Contributing

All development of template is performed in the master branch. Please send PRs with bug fixes to the master branch.

Please refer to the contributing guide for more details.

Thanks

We test Apple Silicon support with MacStadium. macstadium

License

Copyright 2019 IceRock MAG Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...
Opinionated Redux-like implementation backed by Kotlin Coroutines and Kotlin Multiplatform Mobile

CoRed CoRed is Redux-like implementation that maintains the benefits of Redux's core idea without the boilerplate. No more action types, action creato

An app architecture for Kotlin/Native on Android/iOS. Use Kotlin Multiplatform Mobile.
An app architecture for Kotlin/Native on Android/iOS. Use Kotlin Multiplatform Mobile.

An app architecture for Kotlin/Native on Android/iOS. Use Kotlin Multiplatform Mobile. 项目架构主要分为原生系统层、Android/iOS业务SDK层、KMM SDK层、KMM业务逻辑SDK层、iOS sdkfra

Gradle plugin for simplify Kotlin Multiplatform mobile configurations
Gradle plugin for simplify Kotlin Multiplatform mobile configurations

Mobile Multiplatform gradle plugin This is a Gradle plugin for simple setup of Kotlin Multiplatform mobile Gradle modules. Setup buildSrc/build.gradle

KaMP Kit by Touchlab is a collection of code and tools designed to get your mobile team started quickly with Kotlin Multiplatform.
KaMP Kit by Touchlab is a collection of code and tools designed to get your mobile team started quickly with Kotlin Multiplatform.

KaMP Kit Welcome to the KaMP Kit! About Goal The goal of the KaMP Kit is to facilitate your evaluation of Kotlin Multiplatform (aka KMP). It is a coll

Kotlin Multiplatform Mobile App Template

KMMT : Kotlin Multiplatform Mobile Template Kotlin Multiplatform Mobile Development Simplified KMMT is a KMM based project template designed to simpli

Playground for learning Kotlin Multiplatform Mobile
Playground for learning Kotlin Multiplatform Mobile

This is a playground for learning KMP (KMM Plugin for android studio). Requirements Android Studio Canary 8 Architecture Thanks https://twitter.com/jo

Ethereum Web3 implementation for mobile (android & ios) Kotlin Multiplatform development

Mobile Kotlin web3 This is a Kotlin MultiPlatform library that ... Table of Contents Features Requirements Installation Usage Samples Set Up Locally C

Location Service Manager for Kotlin Multiplatform Mobile iOS and android
Location Service Manager for Kotlin Multiplatform Mobile iOS and android

Location Service Manager for Kotlin Multiplatform Mobile iOS and android Features Provides simple permission settings Dramatically reduce the amount o

Kotlin Multiplatform Mobile demo for Android and iOS - app for viewing Cat pictures
Kotlin Multiplatform Mobile demo for Android and iOS - app for viewing Cat pictures

CatViewerDemo Android demo iOS demo Kotlin Multiplatform Mobile demo for Android and iOS. App for viewing Cat pictures from Cats API. This sample show

Owner
Dizel
android dev.
Dizel
Kotlin Multiplatform Mobile + Mobile Declarative UI Framework (Jetpack Compose and SwiftUI)

Kotlin Multiplatform Mobile + Mobile Declarative UI Framework (Jetpack Compose and SwiftUI)

Kotchaphan Muangsan 3 Nov 15, 2022
An example for who are all going to start learning Kotlin programming language to develop Android application.

Kotlin Example Here is an example for who are all going to start learning Kotlin programming language to develop Android application. First check this

Prabhakar Thota 56 Sep 16, 2022
WordMasterKMP - WIP Kotlin Multiplatform sample inspired by Wordle and also Word Master web sample

WordMasterKMP WIP Kotlin Multiplatform sample inspired by Wordle and also Word M

John O'Reilly 56 Oct 4, 2022
Real life Kotlin Multiplatform project with an iOS application developed in Swift with SwiftUI, an Android application developed in Kotlin with Jetpack Compose and a backed in Kotlin hosted on AppEngine.

Conferences4Hall Real life Kotlin Multiplatform project with an iOS application developed in Swift with SwiftUI, an Android application developed in K

Gérard Paligot 98 Dec 15, 2022
Cross-platform framework for building truly native mobile apps with Java or Kotlin. Write Once Run Anywhere support for iOS, Android, Desktop & Web.

Codename One - Cross Platform Native Apps with Java or Kotlin Codename One is a mobile first cross platform environment for Java and Kotlin developers

Codename One 1.4k Jan 9, 2023
Mobile client for official Nextcloud News App written as Kotlin Multiplatform Project

Newsout Android and iOS mobile client for Nextcloud news App. The Android client is already available to download in the Play Store. F-Droid and Apple

Simon Schubert 118 Oct 3, 2022
Kotlin Multiplatform Mobile application built using that consumes WakaTime API

Kotlin Multiplatform Mobile application built using that consumes WakaTime API ⏱️ to display user's coding stats such as day's or day's of weeks coding time, coding time for various programming languages or worked on projects etc. on various platforms.

Victor Kabata 17 Nov 30, 2022
Runtime Mobile Security (RMS) 📱🔥 - is a powerful web interface that helps you to manipulate Android and iOS Apps at Runtime

Runtime Mobile Security (RMS) ?? ?? by @mobilesecurity_ Runtime Mobile Security (RMS), powered by FRIDA, is a powerful web interface that helps you to

Mobile Security 2k Dec 20, 2022
Simple Android Library, that provides easy way to start the Activities with arguments.

Warning: Library is not maintained anymore. If you want to take care of this library, propose it via Pull Request. It needs adjustmensts for newer ver

Marcin Moskała 429 Dec 15, 2022
ATH Sample is a sample Authentication and Authorization Application with Kotlin Language and MVVM architecture.

ATH Sample ATH Sample is a sample Authentication and Authorization Application with Kotlin Language and MVVM architecture. Overview ATH Sample is a sa

AbolfaZl RezaEi 4 Jun 8, 2021