I am in a situation where I need to integrate a library that is not a part of KMM. Instead, it has separate Android and iOS SDKs. I am unsure about how to integrate it into my KMM project. Do I need to create a KMM library, or is there another way to incorporate these platform-specific libraries into my KMM project?
10/24/2023, 9:03 AM
Yes you can create as a library if you want to share it between projects/opensource it.
You can just "hardcode" implementation into your project.
You add the libraries into appropriate platforms sourcesets, you create in common interaction with the libraries (Common interface) and in the sourcesets you fullfill the common interface
10/24/2023, 9:07 AM
Highly recommended to create a separate library/module for architecture, code distribution and reusability reasons.
Now, either way, a separate library or direct integration into your App. The easiest way I have found so far is defining a common kotlin interface in commonMain main and implementing it in each platform language.
There is another way where you can manually create the kotlin native to objective-c interop bindings for your library, but that requires a bit more work.