Skip to content
Gradle plugin for simplify Kotlin Multiplatform mobile configurations
Kotlin
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper initial commit Aug 28, 2019
src/main improve logs of cocoapods building Feb 16, 2020
.gitignore initial commit Aug 28, 2019
LICENSE.md initial commit Aug 28, 2019
README.md
build.gradle.kts up version Feb 16, 2020
gradle.properties
gradlew initial commit Aug 28, 2019
gradlew.bat

README.md

GitHub license Download kotlin-version

Mobule Multiplatform gradle plugin

This is a Gradle plugin for simple setup of Kotlin Multiplatform mobile Gradle modules.

Setup

buildSrc/build.gradle.kts

repositories {
    jcenter()
    google()

    maven { url = uri("https://dl.bintray.com/icerockdev/plugins") }
}

dependencies {
    implementation("dev.icerock:mobile-multiplatform:0.5.2")
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61")
    implementation("com.android.tools.build:gradle:3.5.3")
}

Usage

Setup gradle module as mobile multiplatform

build.gradle.kts

plugins {
    id("com.android.library")
    id("org.jetbrains.kotlin.multiplatform")
    id("dev.icerock.mobile.multiplatform")
}

Plugin automatically setup android, iosX64, iosArm64 targets. For Android setup sourceset path to androidMain. For iOS setup sync gradle tasks in group cocoapods for cocoapods integration.

Definition of dependencies

val mokoTime = MultiPlatformLibrary(
    android = "dev.icerock.moko:time-android:0.1.0",
    common = "dev.icerock.moko:time:0.1.0",
    iosX64 = "dev.icerock.moko:time-iosx64:0.1.0",
    iosArm64 = "dev.icerock.moko:time-iosarm64:0.1.0"
)

val appCompat = AndroidLibrary(
    name = "androidx.appcompat:appcompat:1.1.0"
)

val myFeature = MultiPlatformModule(
    name = ":mpp-library:feature:myFeature"
)

Setup dependencies

build.gradle.kts

dependencies {
    mppLibrary(mokoTime)
    androidLibrary(appCompat)
    mppModule(myFeature)
}

Setup export as iOS framework

build.gradle.kts

setupFramework(exports = listOf(mokoTime))

mokoTime will be exported to framework header.

Setup CocoaPods interop

build.gradle.kts

cocoaPods {
    podsProject = file("../ios-app/Pods/Pods.xcodeproj") // here should be path to your Pods project

    pod("MBProgressHUD") // create cInterop and link with CocoaPod where schema and module is same
    pod(schema = "moko-widgets-flat", module = "mokoWidgetsFlat") // create cInterop and link with CocoaPod where schema and module is different
    pod(schema = "moko-widgets-flat", module = "mokoWidgetsFlat", onlyLink = true) // not create cInterop - just link framework with this CocoaPod
}

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 can’t perform that action at this time.