Skip to content

Commit ca08184

Browse files
committed
up version
1 parent 114be2f commit ca08184

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

README.md

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ buildscript {
6464
gradlePluginPortal()
6565
}
6666
dependencies {
67-
classpath("dev.icerock.moko:kswift-gradle-plugin:0.6.1")
67+
classpath("dev.icerock.moko:kswift-gradle-plugin:0.7.0")
6868
}
6969
}
7070
```
@@ -95,7 +95,7 @@ project where framework compiles `build.gradle`
9595

9696
```groovy
9797
plugins {
98-
id("dev.icerock.moko.kswift") version "0.6.1"
98+
id("dev.icerock.moko.kswift") version "0.7.0"
9999
}
100100
```
101101

@@ -115,7 +115,7 @@ project `build.gradle`
115115

116116
```groovy
117117
dependencies {
118-
commonMainApi("dev.icerock.moko:kswift-runtime:0.6.1") // if you want use annotations
118+
commonMainApi("dev.icerock.moko:kswift-runtime:0.7.0") // if you want use annotations
119119
}
120120
```
121121

@@ -273,6 +273,45 @@ public extension UIKit.UILabel {
273273

274274
Selector from comment can be used for filters as in first example.
275275

276+
## Generation of Swift copy method for data classes
277+
278+
Enable feature in project `build.gradle`:
279+
280+
kotlin:
281+
```kotlin
282+
kswift {
283+
install(dev.icerock.moko.kswift.plugin.feature.DataClassCopyFeature)
284+
}
285+
```
286+
287+
groovy:
288+
```groovy
289+
kswift {
290+
install(dev.icerock.moko.kswift.plugin.feature.DataClassCopyFeature.factory)
291+
}
292+
```
293+
294+
With this feature for data class like this:
295+
```kotlin
296+
data class DataClass(
297+
val stringValue: String,
298+
val optionalStringValue: String?,
299+
val intValue: Int,
300+
val optionalIntValue: Int?,
301+
val booleanValue: Boolean,
302+
val optionalBooleanValue: Boolean?
303+
)
304+
```
305+
306+
Will be generated swift code that can be used like this:
307+
```swift
308+
let newObj = dataClass.copy(
309+
stringValue: {"aNewValue"},
310+
intValue: {1},
311+
booleanValue: {true}
312+
)
313+
```
314+
276315
## Implementation of own generator
277316

278317
First create `buildSrc`, if you don't. `build.gradle` will contains:
@@ -293,7 +332,7 @@ repositories {
293332
dependencies {
294333
implementation("com.android.tools.build:gradle:7.0.0")
295334
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21")
296-
implementation("dev.icerock.moko:kswift-gradle-plugin:0.2.0")
335+
implementation("dev.icerock.moko:kswift-gradle-plugin:0.7.0")
297336
}
298337
```
299338

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ androidLifecycleVersion = "2.1.0"
66
androidCoreTestingVersion = "2.1.0"
77
coroutinesVersion = "1.6.0-native-mt"
88
mokoTestVersion = "0.4.0"
9-
mokoKSwiftVersion = "0.6.1"
9+
mokoKSwiftVersion = "0.7.0"
1010

1111
mokoMvvmVersion = "0.11.0"
1212
mokoResourcesVersion = "0.16.2"

0 commit comments

Comments
 (0)