Skip to content

Instantly share code, notes, and snippets.

@LiewJunTung
Created April 8, 2019 04:07
Show Gist options
  • Save LiewJunTung/e66672d0ce53d226866883e2ff9f28ad to your computer and use it in GitHub Desktop.
Save LiewJunTung/e66672d0ce53d226866883e2ff9f28ad to your computer and use it in GitHub Desktop.
plugins {
id 'kotlin-multiplatform' version '1.3.21'
}
repositories {
google()
jcenter()
mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
//apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId 'org.jetbrains.kotlin.mpp_app_android'
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName '1.0'
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
}
kotlin {
android("android")
// This is for iPhone emulator
// Switch here to iosArm64 (or iosArm32) to build library for iPhone device
iosX64("ios") {
binaries {
framework("app")
}
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
androidMain {
dependencies {
implementation kotlin('stdlib')
}
}
androidTest {
dependencies {
implementation kotlin('test')
implementation kotlin('test-junit')
}
}
iosMain {
}
iosTest {
}
}
}
// This task attaches native framework built from ios module to Xcode project
// (see iosApp directory). Don't run this task directly,
// Xcode runs this task itself during its build process.
// Before opening the project from iosApp directory in Xcode,
// make sure all Gradle infrastructure exists (gradle.wrapper, gradlew).
task copyFramework {
String buildType = project.findProperty('kotlin.build.type') ?: 'DEBUG'
def target = project.findProperty('kotlin.target') ?: 'ios'
dependsOn "linkApp${buildType.toLowerCase().capitalize()}FrameworkIos"
//kotlin.targets."$target".compilations.main.linkTaskName('FRAMEWORK', buildType)
doLast {
def srcFile = file("$buildDir/bin/ios/app${buildType.toLowerCase().capitalize()}Framework")
def targetDir = getProperty("configuration.build.dir")
copy {
from srcFile
into targetDir
include 'app.framework/**'
include 'app.framework.dSYM'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment