https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

ansman

09/15/2019, 6:32 PM
Is it possible to use the same code between multiple iOS targets? I don’t really want to redefine my
actual
stuff for every iOS target
d

Dominaezzz

09/15/2019, 6:41 PM
You can share a sourceSet between the targets or share a source folder.
a

ansman

09/15/2019, 6:42 PM
Yeah, that’s what I figured. Any examples? Do I just have to do it manually or is there a build in way?
a

ansman

09/15/2019, 6:44 PM
Right, thanks! It would be nice if there was an alias for iOS that would add all targets
l

louiscad

09/16/2019, 8:33 AM
In this module, I do it to share code between macOS and all iOS targets (3 CPU architectures): https://github.com/LouisCAD/Splitties/tree/aa28eaaa6da877f09f8565ec6c6f4d3825b2d291/modules/preferences All the "magic" that allows this to work well in the IDE is here: https://github.com/LouisCAD/Splitties/blob/aa28eaaa6da877f09f8565ec6c6f4d3825b2d291/buildSrc/src/main/kotlin/config/KotlinSourceSetsConfig.kt#L40 And here's the (Kotlin) script that creates the proper symlinks and directory structure for each target I want to add: https://github.com/LouisCAD/Splitties/blob/aa28eaaa6da877f09f8565ec6c6f4d3825b2d291/scripts/Add-Kotlin-Targets.kts
9 Views