Skip to content

Instantly share code, notes, and snippets.

@wongk
Created November 19, 2019 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wongk/c1ed9dd728ad0b971e93e12878849c00 to your computer and use it in GitHub Desktop.
Save wongk/c1ed9dd728ad0b971e93e12878849c00 to your computer and use it in GitHub Desktop.
Blog - Umbrella Project - build.gradle.kts
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
buildscript {
project.extra["iosFrameworkName"] = "iOSAppUmbrella"
repositories {
google()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.1")
}
}
plugins {
kotlin("multiplatform")
}
repositories {
jcenter()
}
kotlin {
iosX64("iosX64")
iosArm32("iosArm32")
iosArm64("iosArm64")
sourceSets.create("iosMain") {
dependencies {
implementation(kotlin("stdlib-common"))
api(project(":MyProjectA"))
api(project(":MyProjectB"))
}
}
targets.withType<KotlinNativeTarget> {
compilations["main"].defaultSourceSet {
dependsOn(sourceSets["iosMain"])
}
binaries.framework {
baseName = "${project.extra["iosFrameworkName"]}"
// We need to link the cinterop framework used by MyProjectA, so inform
// the linker of the framework"s path.
linkerOpts.add("-F${project(":MyProjectA").projectDir}/c_interop")
export(project(":MyProjectA"))
export(project(":MyProjectB"))
}
}
}
tasks.register("fatFramework", FatFrameworkTask::class) {
// The fat framework must have the same base name as the initial frameworks.
baseName = "${project.extra["iosFrameworkName"]}"
val frameworks = mutableListOf<Framework>()
kotlin.targets.withType<KotlinNativeTarget> {
frameworks.add(binaries.getFramework("RELEASE"))
}
// Specify the frameworks to be merged.
from(frameworks)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment