I wondered if with Swift something like Kotlin Multiplatform is possible as well.
So that all the core logic would be written in Swift and for the UI I would use the native stack of the platform itself. Currently I'm not planning to build an app that requires a version for Apple, Android, Linux, Windows, and web. But I'm curious if someone has already some experience in creating a monorepo for all that platform that is scalable and maintainable. How much effort would this take to make that possible?
This is basically the approach that The Browser Company has taken and applied successfully for Arc and Dia. Both are extremely large projects and it has worked quite well.
I've been doing this for a while in a decently complex app, and I would say that the approach depends on several factors stemming from your app domain. To name a few:
What's your "core logic" made of? As in, is the app more UI or logic?
How does your data flow? Is it UI → Core (pull) or do you also need events/callback behavior like Core → UI (push)?
How asynchronous do you want it to be?
Is the Core platform-agnostic or very tied to the platform differences?
Do you have non-Swift dependencies?
Do you use SwiftPM or CMake?
I believe the answer to these questions could make the choice of sharing Swift logic a great bet or a lot of extra work. By that, I mean that in some cases, duplicating the native code could lead, paradoxically, to less maintenance than designing a shared core that fits heterogeneous platforms and programming languages.
But probably I had a wrong understanding about Swift + WASM. For me it would be nice if I could share "Core logic“ (network calls, data models, etc.) between all platforms and just have a different UI on every platform. But I think this isn't possible, right?
That is exactly the model that I was mentioning upthread. The model that The Browser Company uses is precisely this: the core Arc/Dia logic is shared, and the UI layer is per platform (Windows using the Windows UI primitives and macOS using the macOS UI primitives).
Yes true, I was more thinking of the networking + Codable and JSONDecoder /Encoder, if this will work on all platforms. Probably when I would use the Async HTTP Client it would work, right?
Currently I will start with a SwiftUI client + Vapor backend and Core library for sharing types, maybe later I will expand to more platforms based on demand. Would you recommend going for a mono or multi repo when starting out with the project?
Many core libraries work but there are API gaps on some platforms, and as for general Swift packages, you can check the index for platform compatibility. I have never built a full Swift GUI app, only command-line executables, so can't answer questions about repo organization and so on.