Hi all ... I've been reading about GitPortal (have...
# touchlab-tools
b
Hi all ... I've been reading about GitPortal (haven't actually tried it yet). I have a question. When you link your android/ios repos with your KMP repo, you wind up with a copy of the KMP source code in your app repos. In the tutorial, it puts it into a "library" folder. Is the intention that the (KMP) code in the "library" folder should be committed to the app's github repo?
k
Is the intention that the (KMP) code in the "library" folder should be committed to the app's github repo?
Yes I started writing up a long post about how it works internally last night, but it got offensively long pretty quickly. Mostly because I like to sidebar about things. In summary, there are 3 "repo linking" options that are generally available: • submodule • subtree • subrepo The first 2 are "official" git things, although submodule is more "official" than subtree. submodule does not store the code in the consuming repo. The other two options do. The general idea is that submodule puts its complexity right out in front to the developer, while the other two try to keep the complexity to admins or CI (generally). GitPortal is a rewrite of subrepo. Long story. For what GitPortal does, the source really needs to be in the app/consuming repo. This is one of several reasons why submodule wasn't the underlying tech used. In "unidirectional" mode, it's not that important. You could implement something similar with submodule, although it's pretty easy to get into trouble with submodule. In "bidirectional" mode, the whole point is that you edit the app code and KMP code in the app repo, and KMP changes are shared by CI. Also, I guess as an FYI, the sample folder is "library", but it can be any folder, or a subfolder. Also, FYI, all 3 options take all of the code in the "other" repo and stick it in a folder in the app/consuming repo.
b
> it got offensively long pretty quickly. Mostly because I like to sidebar about things. haha I get that. The running joke at our office is that when I send messages on slack, people ask ChatGPT to summarize it for them cause it's so long 🤦
thanks for the explanation. The more I thought about it, the more it makes sense, particularly in a team environment. If i create a
new-feature
branch in my ios project and do some work, and then a team member pulls
new-feature
to work on it, how do they know which "version" of the KMP code goes with that branch? Keeping the code in the app repo solves that problem. The KMP code is part of my ios app, just like all of the swift code (it's just compiled with a different compiler) so of course it should be in the app repo. That's sort of what made it click for me.
k
The KMP code is part of my ios app, just like all of the swift code (it's just compiled with a different compiler) so of course it should be in the app repo.
Yeah, that. Exactly. submodule is more generally used for importing library code. The mental "switch" I'm trying to push here is that the KMP code isn't library code. It's part of the app, Android or iOS. The difficulty is if both apps and KMP code are in the same repo, you can't edit either app safely without potentially changing the KMP code, then impacting the "other" app. So, there's more potential overhead for each change, and the teams are now "coupled". Splitting the apps, but syncing the KMP, could maybe solve that problem (we'll see what people think). Yesterday's post starts to get into the problems, but doesn't talk about solutions: https://touchlab.co/kmp-teams-piloting-vs-scaling More posts coming.
👍 1
b
Yep, that all make sense. And for us, our apps are pretty big, so there would be some concern just about the sheer size of the repo if we had both apps and the kmp all together in a single repo. We also have an added piece of complexity in that the same business logic we use in our apps, we want to be able to package into an sdk that is used in some white label apps (some of which may not even be built by us). The separate repo's helps with that. We can use GitPortal to pull the KMP code into our apps, and also use the KMP repo to produce android/ios sdk's that can be used in white label apps. That's the idea at least.
k
Let me know if you're going to try it out. I can help with issues. It's a bit of an odd tool. I'm getting interesting usability feedback. For example, you need to run operations from the git repo root, but some folks expected to run operations from the app root (app was a sub folder), or from the shared folder directory. Just things I wasn't doing when writing it.
It would be simple to find the repo root from wherever you are, but should the operation then run from the repo root, or from where you are? Anyway...