Is it possible to create a Multiplatform library a...
# multiplatform
k
Is it possible to create a Multiplatform library and publish it in Cocoapods? We are aiming to create a library that will ease an usage of our API by hiding endpoints behind library API. We want to write two separate libraries to support both iOS and Android. I thought that maybe it would be a good use-case for KMP, but I’m not sure if it will be possible to publish it in Cocoapods to let iOS developers easily integrate the library
👍 1
k
Thanks 👍
c
Is it not the case that you probably won't want to do this, because your library will be necessarily very large as it includes practically the entire Kotlin world. And also, any KN libs a consuming app uses will also contain this?
k
Do you have any examples how big (in terms of size) would be a very simple iOS library built with KMP? I would like it to use at least ktor, serialization and probably SQLDelight, so it would also make it bigger
☝️ 1
k
“because your library will be necessarily very large as it includes practically the entire Kotlin world” No, it is not the case. The compiler only includes what you’re using, not the whole Kotlin world. We’ve done fairly extensive size tests. How big you binary will be will depend on what you actually do with it. With no libraries and basic string functions, you’d be looking at about 150k download and 500k on disk. For our droidcon app, with sqldelgiht, serialization, ktor, plus several other libraries and some code, 1.5m download and 4.5m on disk. If I took a wild guess, you’d be more like 1m download and 3-4m on disk.
👍 1
Those numbers are the effect that adding that Kotlin library had on the total app size in app store connect.
We have a long overdue blog post on this.
k
Thank you for the deep answer. Actually the first thing I did after starting working on the library was checking how big is it. So I created a framework that exposed simple data class with one field. After adding it to a legacy iOS project I observed 200 kB difference in compare to the app without this pod (I compared only
.ipa
files)
@kpgalligan could you point me to this blog post?
k
By “long overdue” I mean I haven’t written it yet. I’m not sure about comparing ipa, but the most accurate test is pushing to app store connect and looking at estimates. There are other ways to look locally, but they’re not as clear (although generally OK). 200k seems quite reasonable, especially for iOS 🙂
k
OK, thank you 🙂