How to properly add submodule inside shared module and make it accessible in its source sets?

I am migrating this project of mine to KMM. Both iOS and Android runs the basic Greeting function, but the real challenge starts when trying to access feature modules classes like ViewModel in shared module source set.

Having this structure, I want to wrap it using shared module.


I tried to moved the feature modules from androidApp module to shared module

I am reading this documentation where it says it’s possible to do this (if my understanding is correct) with the umbrella module which I assumed is by using the shared module.

I cannot proceed due to the following problems:

  1. Koin core is not accessible in common and ios source set of shared module.
  2. ViewModels is not accessible in common, android, ios source set of shared module.

It seems nothing from the commonMain dependencies block is accessible in those source set.

Update, it seems ViewModels are accessible on androidMain source set with the above setup but not for commonMain or iosMain.

Found the solution thanks to this SO question. Then next thing to do is to move all declared api except ksp from dependencies block to sourceSets block commonMain.dependencies so libraries like Ktor, Koin, or Room are also accessible via transitive.