What does the open sourcing of swift-build mean?

Hey, i'm curious as to how and what the recent open sourcing of swift-build to mean - does it mean you can use swiftpm to develop ios apps and no longer be locked to xcode? does it mean you can use xcodebuild and swiftpm interchangebly? does it mean xcodes build system is no longer proprietary? is swift-build a part of xcodebuild? xcodebuild is not only for swift but for objc/c/c++ too, how does swift-build fit in that role?

From my understanding, no, no, yes, yes, and swift-build is language agnostic.

4 Likes

I had the same confusion when I read the blog post on swift.org. I wonder what are the things that the original SPM build system can't do but swift-build does? IIRC the blog post didn't list them. My impression was that it would improve the interoperability between SPM build system and Xcode's build system, though I have no idea what exactly it means and why it matters.

One very key difference is that swift-build / Xcodebuild supports mixed C family and Swift source modules. This opens up the possibility of exposing the "Swift" module (and other stdlib modules) in a swift package and would make producing Swift standard libraries with custom triples / ABIs dramatically easier.

8 Likes

Looking at Mac only:
Currently, you can build swift packages in Xcode and via the CLI, but when doing it via CLI, the SwiftPM build system gets invoked and when doing it via the play button in Xcode you use swift-build.
There are some edge-cases where one build fails and the other one works. Also, when new features are added to the SwiftPM build system, Apple needs to port it over to swift-build, which can take some time.

In future, no matter on which platform, and which application you build your Swift code, swift-build will always be invoked, so there are no differences anymore.

Additionally, swift-build supports much more options which can be passed to the build system (at least all the ones in Xcode projects, probably even more) which any other build system could make use of.
So in future, when swift-build is stable in SwiftPM, proposal authors have a much broader build system to build feature upon which could be integrated into SwiftPM.

7 Likes