I am trying to make an iOS + Android + web library for exposing device functionality, and some platforms require dependencies to construct the platform driver. How should a library handle getting platform specific dependencies of a running instance of an app (e.g. Android
Context
, iOS `UIViewController`/`AppDelegate`, etc.)? A global
fun getInstance()
will only be sufficient for platforms that don’t require dependencies.
p
Pablichjenkov
12/19/2023, 2:54 AM
CommonMain will declare an interface that will be implemented in each platform and injected using either a DI framework or manually passing it to your library initializer.