• Stars
    star
    452
  • Rank 93,457 (Top 2 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Template project of a Mobile (Android & iOS) Kotlin MultiPlatform project with the MOKO libraries and modularized architecture

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.

More Repositories

1

moko-mvvm

Model-View-ViewModel architecture components for mobile (android & ios) Kotlin Multiplatform development
Kotlin
951
star
2

moko-resources

Resources access for mobile (android & ios) Kotlin Multiplatform development
Kotlin
945
star
3

moko-widgets

Multiplatform UI DSL with screen management in common code for mobile (android & ios) Kotlin Multiplatform development
Kotlin
363
star
4

moko-kswift

Swift-friendly api generator for Kotlin/Native frameworks
Kotlin
335
star
5

moko-permissions

Runtime permissions controls for mobile (android & ios) Kotlin Multiplatform development
Kotlin
249
star
6

libs.kmp.icerock.dev

Kotlin Multiplatform libraries list with info auto-fetch
JavaScript
229
star
7

moko-network

Network components with codegeneration of rest api for mobile (android & ios) Kotlin Multiplatform development
Kotlin
147
star
8

moko-geo

Geolocation access for mobile (android & ios) Kotlin Multiplatform development
Kotlin
113
star
9

moko-socket-io

MOKO SocketIo by IceRock is Socket.IO implementation Kotlin Multiplatform library
Kotlin
93
star
10

mobile-multiplatform-gradle-plugin

Gradle plugin for simplify Kotlin Multiplatform mobile configurations
Kotlin
92
star
11

moko-maps

Control your map from common code for mobile (android & ios) Kotlin Multiplatform development
Kotlin
71
star
12

moko-media

Media selection & presenting for mobile (android & ios) Kotlin Multiplatform development
Kotlin
66
star
13

moko-parcelize

@Parcelize support for mobile (android & ios) Kotlin Multiplatform development
Kotlin
60
star
14

moko-paging

Pagination logic in common code for mobile (android & ios) Kotlin Multiplatform development
Kotlin
57
star
15

moko-errors

Automated exceptions handler for mobile (android & ios) Kotlin Multiplatform development.
Kotlin
52
star
16

moko-web3

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

moko-biometry

Biometry authentication with Touch ID, Face ID from common code with Kotlin Multiplatform Mobile
Kotlin
34
star
18

moko-crash-reporting

Fatal and Non-Fatal reporting to Crashlytics for Kotlin Multiplatform Mobile
Kotlin
26
star
19

moko-units

Composing units into list and show in RecyclerView/UITableView/UICollectionView. Control your lists from common code for mobile (android & ios) Kotlin Multiplatform development
Kotlin
25
star
20

kmm.icerock.dev

JavaScript
22
star
21

redwood-sample

Kotlin
20
star
22

moko-fields

Input forms for mobile (android & ios) Kotlin Multiplatform development
Kotlin
19
star
23

moko-graphics

Graphics primitives for mobile (android & ios) Kotlin Multiplatform development
Kotlin
16
star
24

moko-javascript

JavaScript evaluation from kotlin common code for android & iOS
Kotlin
14
star
25

moko-tensorflow

Tensorflow Lite bindings for mobile (android & ios) Kotlin Multiplatform development
Kotlin
14
star
26

moko-core

Core classes for mobile (android & ios) Kotlin Multiplatform development
Kotlin
13
star
27

shaper

File structure generation tool from templates on Handlebars
Kotlin
12
star
28

moko-test

Test utilities for mobile (android & ios) Kotlin Multiplatform development
Kotlin
11
star
29

moko-widgets-template

Template project of a Mobile (Android & iOS) Kotlin MultiPlatform project with the MOKO widgets and other MOKO libs
Kotlin
10
star
30

kotlin-version-badge

badge with kotlin version, automatically fetched from mavenCentral package of latest version
Kotlin
10
star
31

moko

MOKO libraries umbrella project
Kotlin
9
star
32

gpuimage-filters-editor

iPad application photo editor with filters by GPUImage
Objective-C
9
star
33

codelabs.kmp.icerock.dev

Education of Kotlin Multiplatform Mobile
JavaScript
8
star
34

mobile-multiplatform-education

Internal lessons of mobile multiplatform development
Kotlin
8
star
35

email-service

Email sending service for kotlin - part of BOKO libs
Kotlin
7
star
36

moko.icerock.dev

Home page of moko libraries
HTML
7
star
37

moko-doctor

doctor script for checking the KMM developer's environment
Shell
6
star
38

admin-toolkit

Toolkit to create admin panels - part of BOKO libs
TypeScript
6
star
39

binance-futures-kotlin-api

Kotlin
6
star
40

sms-service

Sms sending service for kotlin - part of BOKO libs
Kotlin
5
star
41

storage-service

Tools for work with s3 storage and generate preview - part of BOKO libs
Kotlin
5
star
42

fcm-push-service

Tools for sending fcm push by kotlin - part of BOKO libs
Kotlin
5
star
43

yellowdoor-app

Kotlin
4
star
44

prototyping.icerock.dev

JavaScript
4
star
45

moko-time

Timestamp and timers for mobile (android & ios) Kotlin Multiplatform development
Kotlin
4
star
46

moko-gradle-plugin

Kotlin
3
star
47

moko-utils

Utilities for mobile (android & ios) Kotlin Multiplatform development
Kotlin
3
star
48

db-utils

Common tools for work with postgres via exposed - part of BOKO libs
Kotlin
3
star
49

web-utils

Common tools for create web application (ktor based) - part of BOKO libs
Kotlin
3
star
50

tinkoff-merchant-api

Tinkoff Merchant API Kotlin Client - part of BOKO libs
Kotlin
3
star
51

moko-intellij-plugin

Kotlin
3
star
52

slackbot-gitlab-ci

GitLab CI slackbot (beepboophq.com version)
JavaScript
2
star
53

auth-service

Common tools for JWT auth - part of BOKO libs
Kotlin
2
star
54

icerock-talaiot-config-plugin

Kotlin
2
star
55

PopupBottomNavigation

Popup menu with additional tabs for UITabBarController
Swift
2
star
56

IRPDFKit

PDF viewer with search for iOS
JavaScript
2
star
57

kafka-service

Common tools for kafka - part of BOKO libs
Kotlin
2
star
58

boko-validation

Konform based validation for Kotlin/JVM - part of BOKO libs
Kotlin
2
star
59

delivery.icerock.dev

Handlebars
1
star
60

shaper-templates

Templates for Shaper generation tool
Handlebars
1
star
61

kmp.icerock.dev

Kotlin Mobile MultiPlatform materials landing
HTML
1
star