Reputation: 759
I want to build a cross-platform library for both ios and android native projects. The library will contain just some business logic nothing related to the UI, sort of how the KMM is structured.
If I built a KMM plugin, KMM projects can use it, but can the ios/android native projects import and use them as well?
Edit: Consider the consumer of the library is just a native ios app and not a KMM project. I do not want to suggest them to convert their project to a KMM project.
If yes would you please share any example libraries?
If no are there any other solutions I can use to build a library to support all different projects android/ios/KMM?
Upvotes: 5
Views: 3815
Reputation: 10940
Including a KMM module into an existing iOS app does not require any sort of conversion of the existing iOS app. The KMM shared component can be developed on its own, and included in the iOS project by adding it in the iOS project's podfile, then methods from it can be called like any other third-party library. You can find more about KMM CocoaPods integration here.
# this is the only change needed in the iOS project (in the podfile)
pod 'mymodule', :path => '/path/to/kmm/project'
In the KMM project itself, you would configure the iOS target in the gradle file and point it back at the iOS project. There are more details about this here
kotlin {
ios()
cocoapods {
summary = "Core library summary"
homepage = "https://www.myproject.com"
ios.deploymentTarget = "14.0"
podfile = project.file("/path/to/ios/project/podfile")
}
//...
}
There are a lot of KMM samples available in addition to the documentation above, and some details here about how to create a KMM project in Android Studio.
Upvotes: 4