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

GarouDan

11/14/2018, 1:57 AM
One another doubt of mine is, can we have more than one common source set in the same module? For example, this way we could have an expect class statement just for a specific business domain, like the mobile one. If we put the expect in the common source set the js platform, for example, will need to implement this too. Putting this information on a different source set we could use something like depends on to accomplish that. I know that this problem can be solved with two or.more modules but I was wondering if we can do that in the same module too.
k

kpgalligan

11/14/2018, 2:51 PM
I did something like this. There’s commonMain, then nativeCommonMain, then appleMain. All of the targets for apple depend on that because I had a different native implementation only available in apple foundation classes. Haven’t tried it, but I’m guessing I could just add a new expect in nativeCommon. I would think something like “mobileCommon” would work. The source completion stops working 100%, though
h

h0tk3y

11/14/2018, 6:27 PM
Yes, granular code sharing in the way you described it is one of the goals of the new multiplatform model. Reusing parts of the code by arbitrarily directing them to the compilations (using
dependsOn
) is what should allow for such use cases. Due to the current limitations, those custom source sets cannot use the platform-specific libraries and language features, and, when your project is used as a dependency, the declarations placed in custom source sets are not available in common source sets of other projects. Both are technical limitations, and we are working on improving support for this use case.
👍 1
g

GarouDan

11/16/2018, 12:24 PM
@h0tk3y, Is there a issue for this, so I could watch? Thanks in advance
h

h0tk3y

11/22/2018, 11:21 AM
@GarouDan Sorry for the delay. This is the issue for the feature group: https://youtrack.jetbrains.com/issue/KT-27801
2 Views