https://kotlinlang.org logo
#touchlab-tools
Title
# touchlab-tools
t

Thomas Richtsfeld

11/08/2023, 5:22 PM
Hey everyone 👋 We have the following “standard” use case: Android and shared modules in one repo and iOS in a different repo. Q: Is it possible to publish the artefacts and the
Package.swift
file in a different repository other than where the Android code and the shared code lives? Something like:
Copy code
kmmbridge {
    spm(githubUrl = "<https://api.github.com/repos/company/company-ios-all-shared>")
}
I am asking cause I fear that if we use the Android repository for publishing iOS artefacts could lead to increased build time if the Android repo contains lots of files (e.g. images from snapshot tests,…)
k

kpgalligan

11/08/2023, 5:37 PM
That was a use case Russell had early on. It's less common and more complex, so it was pulled before we released the initial version. I'll have to think through how to best approach it. Short answer, that is certainly possible, but would need some plumbing.
s

Stylianos Gakis

11/08/2023, 8:15 PM
So the suggestion for such teams is to extract shared code into a third repo or bring iOS into monorepo right?
k

kpgalligan

11/08/2023, 8:27 PM
I just had a wild idea. I don’t know if I want to say it out loud just yet.
Create a new repo, that’s just for a swift package manager. Include the android repo as a sub module. Normally, I’m against sub modules, but you could take the pain out of this one by automating the sub module complexity.
then again, that might not work. If Xcode tries to get sub modules, it’ll be the same problem.
t

Thomas Richtsfeld

11/09/2023, 7:02 AM
So the suggestion for such teams is to extract shared code into a third repo or bring iOS into monorepo right?
Yes, we want to extract the shared code into a third repo. By shared code in this context we mean the binaries that are created, but not the code itself
then again, that might not work. If Xcode tries to get sub modules, it’ll be the same problem.
So you are saying this won’t work anyway? When you talk about sub modules, do you mean the functionality in Github? Just asking as I don’t have any experience with that. All in all, do you think it is a lot of overhead if we just publish the binaries in the repo where the Android code and the shared code lives (Normal KMMBrisgde approach)? One of our iOS devs just raised the concern that it could lead to increased build times when the whole repo needs to be loaded on iOS. Which I understand as this is unnecessary because as far as I know SPM just needs to know the location of
Package.swift
right? We were already using KMP in a repo that was outside of the Android one. We did exactly that • The
Package.swift
file was published to it’s own repo while the
binaryTarget
url was pointing to the released zip file that lived in the shared repo
k

kpgalligan

11/09/2023, 3:13 PM
> So the suggestion for such teams is to extract shared code into a third repo or bring iOS into monorepo right?
Yes, we want to extract the shared code into a third repo. By shared code in this context we mean the binaries that are created, but not the code itself
To clarify, you are talking about different things. Pulling shared code into a 3rd repo and using a 3rd repo only to manage SPM dependencies. As a general recommendation, it really depends. If Android is where the main dev really happens, and iOS generally follows after, I wouldn't pull the shared code into a 3rd repo. It will likely slow down dev. If the team is larger and you'd pull an SDK out anyway, then it makes more sense. Also, if you are just trying out KMP or for whatever reason start with a 3rd repo, that's OK too.
So you are saying this won’t work anyway?
I don't know. I thought of it while walking somewhere and used speech recognition to send that from my phone. Just thinking out loud.
When you talk about sub modules, do you mean the functionality in Github?
Well, git specifically. It's not special to GitHub. Essentially you can have one git repo inside another. That's beet possible for a long time. Sounds nice, but managing that sucks. However, if the only interaction with submodules was with CI, you wouldn't need to manage it. As for "would it work", I'm not sure how Xcode handles submodules when doing package resolution. When you clone a repo, you need to explicitly ask to clone submodules as well. If Xcode doesn't do that, then this should "work". Would need to try it.
t

Thomas Richtsfeld

11/10/2023, 3:18 PM
Alright, was not sure if you mean the Git feature. Our main development for Android and shared happens in one Repo. iOS is in a different repo. We don’t want to pull the shared code into a 3rd repository as it makes Android development easier if we keep it in the same repo. My question was more like about publishing the binaries into a 3rd repo. As this is not possible with KMMBridge right now, we need to stitch this solution if using KMMBridge. Thanks for the fast replies guys. You are doing a great job there 👍
s

Stylianos Gakis

11/10/2023, 3:20 PM
Interestingly, there was a discussion kinda on the same topic (sharing the SPM package somewhere else) over here https://x.com/GakisStylianos/status/1722965584080429537 today
k

kpgalligan

11/10/2023, 3:20 PM
No, I get what you're saying. It is possible to just publish to a 3rd repo, but that isn't supported out of the box right now, certainly. What I was saying is maybe it could be supported with the following... (it'll be a minute. Doing diagrams)
👀 1
t

Thomas Richtsfeld

11/10/2023, 3:23 PM
Haha, alright waiting for it….
k

kpgalligan

11/10/2023, 3:38 PM
This is the setup where Android, the shared Kotlin module, and SPM publishing would all live. Simple, but it'll be a mess for a number of reasons mentioned above
The iOS project points at that to get the SPM package.
This is what you want to do. Keep Android and shared Kotlin in the Android repo, publish SPM to a separate repo that only deals with SPM packages and versioning.
👍 1
What I'm saying might work is to create that separate repo, have that include the Android repo as a git submodule. Why? Well, in theory, the setup to build and publish for SPM could be much simpler. When you clone or edit just the Android repo, you don't know about, or care about, the wrapper repo. The only entity that modifies the wrapper repo would be CI, when you tell it to build and publish SPM. Xcode would reference that repo for builds.
Forgot the diagram...
I think that would make setup and config a lot simpler than option 2 (fully separate), but I'm not sure. Also, if you wanted the publishing out of the Android repo because the Android repo is very large, and Xcode doesn't like parsing that, then the question is if Xcode pulls from git and follows submodules by default, which git does not. If it doesn't, this would work. If it does, this would not.
However, I'll have to think about option 2. It might not be as complicated as I'm imagining (and we had a POC, so it wasn't entirely in my head. It wasn't simple).
s

Stylianos Gakis

11/10/2023, 3:47 PM
So KMMBridge doe not have a good story regarding doing this https://kotlinlang.slack.com/archives/CTJB58X7X/p1699630743292279?thread_ts=1699464128.748599&cid=CTJB58X7X scenario right?
Btw love the little diagrams you whipped up this quickly, I would’ve done a horrible job in comparison 😄 What tool do you use?
t

Thomas Richtsfeld

11/13/2023, 7:51 AM
Alright, got it. Indeed those small diagrams make it so much easier to understand 💪 . We will give it a try and let you know what worked for us. Before we have to solve some different problems as KMMBridge is not running on CI for us on the first place. I posted an issue on the KMMBridge GHA plugin page. I think I will open another discussion in this slack channel if no one can help on Github for the next days
k

kpgalligan

11/15/2023, 7:44 PM
I'll be getting back to KMMBridge updates over the next few days. This week got a little busy (had a baby Monday 🙂 )
🙌 1
@Stylianos Gakis BTW, diagram tool. Keynote on Mac. I mostly avoid the stock mac tools, but Keynote is honestly amazing. I do all my talks with it, and diagrams are great. It's also great for code. Copy/paste right from Intellij or Xcode and it retains color and style.
thank you color 1
👍 1
s

Stylianos Gakis

11/15/2023, 8:38 PM
Congrats on the baby! 🥳🥳
gratitude thank you 1