My use-case: I already have a modular Android app ...
# multiplatform
c
My use-case: I already have a modular Android app and I want to add iOS. Here's the structure
Copy code
MyApp
  - app
  - feature1_domain
  - feature1_presentation
  - feature2_domain
  - feature2_presentation
  - and so on
All the _`domain` modules serve the purpose of
common
in KMP (they have platform-agnostic code already).
app
, and all the
_presentation
modules have Android-specific code. Wondering what's the best approach to add iOS here. From what I understand, the goal is to generate a single
.framework
from the common code for use in iOS. I did not find any examples of this
k
i would separate cross-platform code into modules based on function
1
and yes, you will need to pull all your iOS modules into one umbrella framework
s
Something like:
Copy code
MyApp //Android depends on MyAppLib
  - app
  - feature1_presentation
  - feature2_presentation
  - and so on
MyAppIOS //depends on MyAppLib.framework (umbrella framework)
MyAppLib //Android & iOS lib
  - feature1_domain
  - feature2_domain
  - and so on
c
I'm not sure I understand. The structure I presented is a single project with multiple gradle modules. Are you suggesting making sub-projects?
k
or separate repos
c
So there isn't a way to create a "shell" module that depends on other platform-agnostic modules and generates a .framework out of them?
k
yes, you can do that
c
Thinking out aloud, all my
_domain
modules are currently are
apply plugin: 'kotlin'
and
apply plugin: 'java-library'
I could turn them all into
Copy code
apply plugin: 'org.jetbrains.kotlin.multiplatform'
Wait I'm confused now. I still don't know how the sourceSet setup works with gradle modules. Maybe I should give it a try first 😄
k
would probably help make it clearer
There is a little problem with the setup, but we found 2 workaround to fix on android. Ios works, the result 1 single framework dependency.
👍 1
k
What I did was create another module just for iOS.
Copy code
Android:
- app
- feature-1
- feature-2

Shared:
- shared-feature-1 (domain and data)
- shared-feature-2 (domain and data)
- shared-ios
shared-ios
just exports the modules through
export(project(:shared-feature-1
and all other modules and you can consume it in android normally.
👍 1