@@ -64,7 +64,7 @@ buildscript {
64
64
gradlePluginPortal()
65
65
}
66
66
dependencies {
67
- classpath("dev.icerock.moko:kswift-gradle-plugin:0.6.1 ")
67
+ classpath("dev.icerock.moko:kswift-gradle-plugin:0.7.0 ")
68
68
}
69
69
}
70
70
```
@@ -95,7 +95,7 @@ project where framework compiles `build.gradle`
95
95
96
96
``` groovy
97
97
plugins {
98
- id("dev.icerock.moko.kswift") version "0.6.1 "
98
+ id("dev.icerock.moko.kswift") version "0.7.0 "
99
99
}
100
100
```
101
101
@@ -115,7 +115,7 @@ project `build.gradle`
115
115
116
116
``` groovy
117
117
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
119
119
}
120
120
```
121
121
@@ -273,6 +273,45 @@ public extension UIKit.UILabel {
273
273
274
274
Selector from comment can be used for filters as in first example.
275
275
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
+
276
315
## Implementation of own generator
277
316
278
317
First create ` buildSrc ` , if you don't. ` build.gradle ` will contains:
@@ -293,7 +332,7 @@ repositories {
293
332
dependencies {
294
333
implementation("com.android.tools.build:gradle:7.0.0")
295
334
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")
297
336
}
298
337
```
299
338
0 commit comments