Skip to content

Commit bf9b232

Browse files
committed
Merge branch 'mpp-add'
2 parents 48122d1 + 06179e9 commit bf9b232

File tree

51 files changed

+1513
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1513
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
gradlew binary
2+
gradlew.bat binary

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*.iml
2+
*.ipr
3+
.idea/
4+
.gradle/
5+
build/
6+
/local.properties
7+
.DS_Store
8+
/captures
9+
.externalNativeBuild
10+
WorkspaceSettings.xcsettings
11+
*.xcuserstate
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright 2010-2018 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
Kotlin MPP Module
3+
=================
4+
5+
6+
An example project of an Kotlin MPP = Multiplatform project for Android and iOS
7+
8+
LICENSE
9+
=======
10+
11+
Apache 2.0
12+
13+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apply plugin: 'kotlin-multiplatform'
2+
3+
4+
kotlin {
5+
targets {
6+
final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
7+
? presets.iosArm64 : presets.iosX64
8+
9+
fromPreset(iOSTarget, 'iOS') {
10+
compilations.main.outputKinds('FRAMEWORK')
11+
}
12+
13+
fromPreset(presets.jvm, 'android')
14+
}
15+
16+
sourceSets {
17+
commonMain.dependencies {
18+
api 'org.jetbrains.kotlin:kotlin-stdlib-common'
19+
}
20+
21+
androidMain.dependencies {
22+
api 'org.jetbrains.kotlin:kotlin-stdlib'
23+
}
24+
}
25+
}
26+
27+
// workaround for https://youtrack.jetbrains.com/issue/KT-27170
28+
configurations {
29+
compileClasspath
30+
}
31+
32+
task packForXCode(type: Sync) {
33+
final File frameworkDir = new File(buildDir, "xcode-frameworks")
34+
final String mode = System.getenv('CONFIGURATION')?.toUpperCase() ?: 'DEBUG'
35+
36+
inputs.property "mode", mode
37+
dependsOn kotlin.targets.iOS.compilations.main.linkTaskName("FRAMEWORK", mode)
38+
39+
from { kotlin.targets.iOS.compilations.main.getBinary("FRAMEWORK", mode).parentFile }
40+
into frameworkDir
41+
42+
doLast {
43+
new File(frameworkDir, 'gradlew').with {
44+
text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n"
45+
setExecutable(true)
46+
}
47+
}
48+
}
49+
50+
tasks.build.dependsOn packForXCode
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package org.kotlin.mpp.mobile
2+
3+
actual fun platformName(): String {
4+
return "Android"
5+
}
6+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.kotlin.mpp.mobile
2+
3+
expect fun platformName(): String
4+
5+
fun createApplicationScreenMessage() : String {
6+
return "Kotlin Rocks on ${platformName()}"
7+
}
8+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.kotlin.mpp.mobile
2+
3+
import platform.UIKit.UIDevice
4+
5+
actual fun platformName(): String {
6+
7+
return UIDevice.currentDevice.systemName() +
8+
" " +
9+
UIDevice.currentDevice.systemVersion
10+
}
11+
12+
13+
14+
//https://stackoverflow.com/a/24505884
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apply plugin: 'com.android.application'
2+
3+
apply plugin: 'kotlin-android'
4+
5+
apply plugin: 'kotlin-android-extensions'
6+
7+
android {
8+
compileSdkVersion 28
9+
defaultConfig {
10+
applicationId "com.jetbrains.jonnyzzz.myapplication"
11+
minSdkVersion 15
12+
targetSdkVersion 28
13+
versionCode 1
14+
versionName "1.0"
15+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16+
}
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
}
24+
25+
dependencies {
26+
implementation project(':SharedCode')
27+
28+
implementation fileTree(dir: 'libs', include: ['*.jar'])
29+
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
30+
implementation 'com.android.support:appcompat-v7:28.0.0'
31+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
32+
testImplementation 'junit:junit:4.12'
33+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
34+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
35+
}

0 commit comments

Comments
 (0)