Apple has open-sourced Swift's build system
You’re more of a video kind of person? I’ve got you covered! Here’s a video with the same content than this article 🍿
Advertisement
Sponsors like Stream really help me grow my content creation, so if you have time please make sure to check out their survey: it’s a direct support to my content creation ☺️
You might have heard the news: Apple has open-sourced Swift's build system.
But what does it mean for app developers?
First, let's talk a bit about what a build system actually is.
A build system is a piece of code that sits on top of the compiler and that orchestrates how your source files are fed to that compiler.
For example, this means building the source code in an order that matches that of dependencies between modules or scheduling the compilation of source files in a way that maximises parallelism.
So now you might be wondering, since the code of this build system is now available on GitHub, does this mean that we can build an iOS app without using Xcode or xcodebuild
?
Well unfortunately, the answer to that question is no.
The reason is that Swift’s build system is only a part of the full build system used by Xcode in order to build an iOS app.
When you want to build an iOS app, you do need to build your Swift code, but you also need to do a lot of others things like handling assets, entitlements, code signature, etc.
And these are steps that only Xcode (or xcodebuild
) can handle.
So at this point, you might be wondering: why does it matter that Apple has open-sourced this Swift build system?
There are actually some very good reasons why it matters!
The first one is that, as of today, there are two different build systems to build Swift code that coexist.
One is used inside Xcode, and that's the one that's just been open-sourced.
And the other is used when you are running the Swift Package Manager by itself.
As I'm sure you know, whenever you have two different pieces of software that are supposed to do the exact same job, you can be sure that there will always be edge cases where they will actually exhibit different behaviours.
So having the Swift build system that’s used in Xcode open-source will make it possible for this build system to be the one that’s used everywhere, on every platform.
That will play a big part in making sure that we have a healthy and reliable package ecosystem, in which developers can be assured that their code will always be built the same way regardless of the context in which it's being built.
Another reason why this is an exciting news, is that developers in the community can now have a look at the Swift build system to better understand it.
This will allow them to both submit suggestions to improve it but also to understand what are the good practices to architecture projects in a way that better matches how the Swift build system operates under the hood.
If you feel adventurous, you might want to spend a few minutes browsing the code of Swift’s build system: you might discover interesting things, like how it actually integrates with Xcode!