Hi, all multiplatform example I read are where the...
# multiplatform
u
Hi, all multiplatform example I read are where the both ios and android apps in the same gradle build/project and in the same git repo I'd like a monorepo for both platforms in our case but its simply not the case and won't be for some time. (each platform has its own git repo) We decided we wanted to wet out feet with kotlin multiplatform by sharing 1 module. So, what would be the best course of action? 1. Create 3rd git repo and extract the module as a standalone gradle project with all the multiplatform settings as necesary 2. somehow build binaries for both platforms, and deploy them to maven/cocoapods. 3. each platform consumes the prebuilt binary for their platform, as any other 3rd party library Sounds doable?
👀 2
a
This is what we do at Quizlet and it works for us (across three platforms because we also use it in web)
The downside is that quick prototyping/iteration is harder. Compared to a monorepo, it's a few extra steps to make a KMP change, publish it, and consume it. Makes TDD in KMP more valuable because having to go back and fix bugs in KMP and re-publish is more painful than with a monorepo
u
@ankushg And you're doing it via the
native.cocoapods
plugin? https://kotlinlang.org/docs/native-cocoapods.html#install-the-cocoapods-dependency-manager-and-plugin now ios colleague tells me cocoa just downloads sources and everything is built from source, huh (for regular ios 3rd party dependency)
u
Maybe
git subtree
can help. It's pretty little known. But I would say it is like git submodule without the flaws.
👍 1
u
I'd rather not change their workflow in the begging as to get multiplatform foot in
👍 1
l
You can simply export a framework for the iOS app.
u
export where
l
Into the Xcode project
u
xcode live in another git repo, manual copying commiting etc wont scale, no versioning etc
l
Then publish the XCFramework as a Swift Package
Or you can publish the library as a KMP library, and have the Kotlin umbrella module sit into the iOS project
u
are the swift packages already built binaries? i read that cocoapods are built from sources locally. and I need cocoapod-binary
l
Both work now for Swift Packages
u
yea but the ios team uses cocoapods, I understand thats a competitir of swift packages?
l
However, I'd personally pick the umbrella Kotlin module in iOS project approach if scalability was a concern. You can perfectly use CocadPods and Swift Packages in the same project, just like you can have electricity and gas in the same house.
u
but youre advocating for swift p. because cocoapods cannot do what I want?
l
I'm only showing you the different ways. The end choice is up to you as you see the advantages and constraints of each option and see what works best for your specific context.
u
yes but cocoapod-binary seemed what I want, but not sure if its feasible. I presume native.cocoapods gradle plugin would have to support that?
come to think of it how can it work from kotlin sources, cocopaods doesnt know kotlin so how can it compile it? prebuilt binary seems like the idea solution, if not working in monorepo
a
from the android side for faster iterations when using separate repos, you should be able to use includeBuild https://docs.gradle.org/current/userguide/composite_builds.html#included_build_declaring_substitutions
👍 1