Skip to content

Commit

Permalink
setup kswift
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex009 committed Aug 9, 2021
1 parent 45e5b91 commit fc92131
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ buildscript {
gradlePluginPortal()
google()
mavenCentral()

maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies")
maven("https://jitpack.io")
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20")
classpath("com.android.tools.build:gradle:7.0.0")
classpath("dev.icerock.moko:kswift-gradle-plugin:0.1.0")
}
}

Expand Down
15 changes: 14 additions & 1 deletion iosApp/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; };
45ABB67626C15F5400D17592 /* shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45ABB67526C15F5400D17592 /* shared.swift */; };
7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; };
/* End PBXBuildFile section */

Expand All @@ -26,6 +27,7 @@

/* Begin PBXFileReference section */
2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };
45ABB67526C15F5400D17592 /* shared.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = shared.swift; sourceTree = "<group>"; };
7555FF7B242A565900829871 /* iosApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iosApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand All @@ -42,9 +44,19 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
45ABB67426C15F5400D17592 /* swift */ = {
isa = PBXGroup;
children = (
45ABB67526C15F5400D17592 /* shared.swift */,
);
name = swift;
path = ../shared/build/generated/swift;
sourceTree = "<group>";
};
7555FF72242A565900829871 = {
isa = PBXGroup;
children = (
45ABB67426C15F5400D17592 /* swift */,
7555FF7D242A565900829871 /* iosApp */,
7555FF7C242A565900829871 /* Products */,
7555FFB0242A642200829871 /* Frameworks */,
Expand Down Expand Up @@ -167,6 +179,7 @@
buildActionMask = 2147483647;
files = (
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
45ABB67626C15F5400D17592 /* shared.swift in Sources */,
7555FF83242A565900829871 /* ContentView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -362,4 +375,4 @@
/* End XCConfigurationList section */
};
rootObject = 7555FF73242A565900829871 /* Project object */;
}
}
17 changes: 16 additions & 1 deletion shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
id("com.android.library")
id("dev.icerock.moko.kswift")
}

kotlin {
Expand Down Expand Up @@ -47,4 +48,18 @@ android {
minSdkVersion(21)
targetSdkVersion(31)
}
}
}

kswift {
install(dev.icerock.moko.kswift.plugin.feature.SealedToSwiftEnumFeature)
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink>().matching {
it.binary is org.jetbrains.kotlin.gradle.plugin.mpp.Framework
}.configureEach {
doLast {
val swiftDirectory = File(destinationDir, "${binary.baseName}Swift")
val xcodeSwiftDirectory = File(buildDir, "generated/swift")
swiftDirectory.copyRecursively(xcodeSwiftDirectory, overwrite = true)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ru.alex009.samples.kswift

sealed interface UIState<out T> {
object Loading : UIState<Nothing>
object Empty : UIState<Nothing>
data class Data<T>(val value: T) : UIState<T>
data class Error(val throwable: Throwable) : UIState<Nothing>
}

0 comments on commit fc92131

Please sign in to comment.