11import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
22
33plugins {
4- kotlin( " multiplatform" )
4+ id( " org.jetbrains.kotlin. multiplatform" )
55 id(" kotlinx-serialization" )
6+ id(" com.android.library" )
67}
78
89kotlin {
10+ ios()
11+ android()
12+
913 // select iOS target platform depending on the Xcode environment variables
1014 val iOSTarget: (String , KotlinNativeTarget .() -> Unit ) -> KotlinNativeTarget =
1115 if (System .getenv(" SDK_NAME" )?.startsWith(" iphoneos" ) == true )
@@ -21,8 +25,6 @@ kotlin {
2125 }
2226 }
2327
24- jvm(" android" )
25-
2628 sourceSets[" commonMain" ].dependencies {
2729 // Kotlin
2830 implementation(" org.jetbrains.kotlin:kotlin-stdlib-common" )
@@ -40,41 +42,78 @@ kotlin {
4042 implementation(" org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.14.0" )
4143 }
4244
43- sourceSets[" androidMain" ].dependencies {
44- // Kotlin
45- implementation(" org.jetbrains.kotlin:kotlin-stdlib" )
46-
45+ sourceSets[" iosMain" ].dependencies {
4746 // Coroutines
48- implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3" )
49- implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3" )
47+ implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.3" )
5048
5149 // Serialization
52- implementation(" org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0 " )
50+ implementation(" org.jetbrains.kotlinx:kotlinx-serialization-runtime-native :0.14" )
5351
5452 // Ktor
55- implementation (" io.ktor:ktor-client-android :1.3.0-rc2" )
56- implementation (" io.ktor:ktor-client-core-jvm :1.3.0-rc2" )
57- implementation (" io.ktor:ktor-client-json-jvm :1.3.0-rc2" )
58- implementation (" io.ktor:ktor-client-logging-jvm :1.3.0-rc2" )
59- implementation (" io.ktor:ktor-client-serialization-jvm :1.3.0-rc2" )
53+ implementation(" io.ktor:ktor-client-ios :1.3.0-rc2" )
54+ implementation(" io.ktor:ktor-client-core-native :1.3.0-rc2" )
55+ implementation(" io.ktor:ktor-client-json-native :1.3.0-rc2" )
56+ implementation(" io.ktor:ktor-client-logging-native :1.3.0-rc2" )
57+ implementation(" io.ktor:ktor-client-serialization-native :1.3.0-rc2" )
6058 }
59+ }
6160
62- sourceSets[" iosMain" ].dependencies {
63- // Coroutines
64- implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.3" )
61+ android {
62+ compileSdkVersion(29 )
63+ buildToolsVersion = " 29.0.2"
64+ defaultConfig {
65+ minSdkVersion(16 )
66+ targetSdkVersion(29 )
67+ versionCode = 1
68+ versionName = " 1.0"
69+ testInstrumentationRunner = " androidx.test.runner.AndroidJUnitRunner"
70+ }
6571
66- // Serialization
67- implementation(" org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.14" )
72+ compileOptions {
73+ sourceCompatibility = JavaVersion .VERSION_1_8
74+ targetCompatibility = JavaVersion .VERSION_1_8
75+ }
6876
69- // Ktor
70- implementation (" io.ktor:ktor-client-ios:1.3.0-rc2" )
71- implementation (" io.ktor:ktor-client-core-native:1.3.0-rc2" )
72- implementation (" io.ktor:ktor-client-json-native:1.3.0-rc2" )
73- implementation (" io.ktor:ktor-client-logging-native:1.3.0-rc2" )
74- implementation (" io.ktor:ktor-client-serialization-native:1.3.0-rc2" )
77+ packagingOptions {
78+ exclude(" META-INF/DEPENDENCIES" )
79+ exclude(" META-INF/LICENSE" )
80+ exclude(" META-INF/LICENSE.txt" )
81+ exclude(" META-INF/license.txt" )
82+ exclude(" META-INF/NOTICE" )
83+ exclude(" META-INF/NOTICE.txt" )
84+ exclude(" META-INF/notice.txt" )
85+ exclude(" META-INF/ASL2.0" )
86+ exclude(" META-INF/*.kotlin_module" )
87+ }
88+
89+ sourceSets {
90+ getByName(" main" ) {
91+ manifest.srcFile(" src/androidMain/AndroidManifest.xml" )
92+ java.srcDirs(" src/androidMain/kotlin" )
93+ res.srcDirs(" src/androidMain/res" )
94+ }
7595 }
7696}
7797
98+ dependencies {
99+ // Kotlin
100+ kotlin(" stdlib" )
101+
102+ // Coroutines
103+ implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3" )
104+ implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3" )
105+
106+ // Serialization
107+ implementation(" org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0" )
108+
109+ // Ktor
110+ implementation(" io.ktor:ktor-client-android:1.3.0-rc2" )
111+ implementation(" io.ktor:ktor-client-core-jvm:1.3.0-rc2" )
112+ implementation(" io.ktor:ktor-client-json-jvm:1.3.0-rc2" )
113+ implementation(" io.ktor:ktor-client-logging-jvm:1.3.0-rc2" )
114+ implementation(" io.ktor:ktor-client-serialization-jvm:1.3.0-rc2" )
115+ }
116+
78117// Used for the xCode integration
79118val packForXcode by tasks.creating(Sync ::class ) {
80119 val targetDir = File (buildDir, " xcode-frameworks" )
0 commit comments