Marcin Wisniowski
06/12/2023, 8:16 PMMarcin Wisniowski
06/12/2023, 8:18 PMkrzysztof
06/12/2023, 10:39 PMMarcin Wisniowski
06/12/2023, 11:50 PMczuckie
06/13/2023, 6:11 AMmultiplatform
plugin to get the ability to create a common target (which comes for free (?) i.e. you don't need to explicitly state you want common code)
• You need to opt in to android, ios, js, wasm, native or desktop
• You can create arbitrary other targets too, like a jvm target that could house jvm common code (imagine a jvm specific library dependency that doesn't have a common implementation, you would want to share that between desktop and android for example, but there wouldn't be a good place to store the shared code without another target)
• Using the multiplatform approach seems to be the most straightforward way to achieve code sharing between desktop and android, even if you don't plan on targeting anything else.
When you create a project using the wizard targeting desktop and android, you end up with 3 modules (desktop, android and common) and inside the common you have 3 targets (not sure that's the correct word). Each common target (common, desktop and android) contain target specific implementations of common defined symbols. At first I was confused why I had so many modules etc, until it clicked that the top level android and desktop modules that were created are consumers of the common module. It forces a separation of your "this is code that should work across all platforms" and "this is really specific to the app on this platform" kind of thing.
Not sure if this helps at all, but it was a bit of an a-ha moment for me!Marcin Wisniowski
06/13/2023, 8:38 AM