-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #7 - Move http and serialization to common
Create a fake `app-ios-lib` module as a workaround for JetBrains/kotlin-native#2423. Update `app-ios` project due to changed framework name. Still not using Kotlin classes for REST + JSON though (for now).
- Loading branch information
Showing
12 changed files
with
89 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
plugins { | ||
id 'kotlin-multiplatform' | ||
id('org.jetbrains.kotlin.native.cocoapods') | ||
} | ||
|
||
kotlin { | ||
targets { | ||
jvm() | ||
iosX64() // iOS simulator | ||
} | ||
|
||
sourceSets { | ||
commonMain { | ||
kotlin.srcDirs = [ | ||
"${project.rootDir}/app-mvp/src/commonMain/kotlin", | ||
"${project.rootDir}/app-infra-rest-ktor/src/commonMain/kotlin" | ||
] | ||
dependencies { | ||
// # using of `implementation project(':...)` does not work and leads to compilation error: | ||
// java.lang.IllegalStateException: IrClassSymbolImpl for deserialized class AddResponseJson is already bound | ||
// (I believe it's because of `app-api` imported twice (1 for both project)) | ||
// implementation project(':app-infra-rest-ktor') | ||
// implementation project(':app-mvp') | ||
|
||
// # -ktor deps | ||
api "io.ktor:ktor-client-core:$rootProject.ktor_version" | ||
api "io.ktor:ktor-client-serialization:$rootProject.ktor_version" | ||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$rootProject.coroutines_version" | ||
// # both -ktor and -mvp deps | ||
implementation 'org.jetbrains.kotlin:kotlin-stdlib' | ||
api "name.antonsmirnov.notes:app-api-metadata:$rootProject.server_module_version" | ||
} | ||
} | ||
iosX64Main { | ||
kotlin.srcDirs = [ | ||
"${project.rootDir}/app-infra-rest-ktor/src/iosX64Main" | ||
] | ||
dependencies { | ||
// # -ktor deps | ||
implementation "io.ktor:ktor-client-ios:$rootProject.ktor_version" | ||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$rootProject.serialization_version" | ||
implementation "io.ktor:ktor-client-serialization-native:$rootProject.ktor_version" | ||
// # both -ktor and -mvp deps | ||
api "name.antonsmirnov.notes:app-api-iosx64:$rootProject.server_module_version" | ||
} | ||
} | ||
} | ||
|
||
// All exceptions in Kotlin are not checked, but in Swift they are checked. | ||
// So we need @Throws annotation for iOS compatibility to generate swift signatures with `.. throws -> ..` | ||
// This requires @ExperimentalMultiplatform annotation in all methods with @Throws. | ||
// In order to prevent adding @ExperimentalMultiplatform every here and there we can use compiler option: | ||
targets.all { | ||
compilations.all { | ||
kotlinOptions { | ||
freeCompilerArgs += '-Xuse-experimental=kotlin.ExperimentalMultiplatform' | ||
} | ||
} | ||
} | ||
} | ||
|
||
version = "$rootProject.module_version" | ||
|
||
kotlin { | ||
cocoapods { | ||
summary = "iOS Kotlin library of NotesClientApp" | ||
homepage = "https://github.com/4ntoine/NotesClientApp" | ||
} | ||
|
||
targets.iosX64.binaries | ||
.findAll { it instanceof org.jetbrains.kotlin.gradle.plugin.mpp.Framework } | ||
.every { | ||
it.export "name.antonsmirnov.notes:app-api-iosx64:$rootProject.server_module_version" | ||
it.transitiveExport = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
// | ||
|
||
import Foundation | ||
import app_mvp | ||
import app_ios_lib | ||
|
||
protocol RestApi : ListNotes, AddNote { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters