Skip to content(if available)orjump to list(if available)

Apple is open sourcing Swift Build

Apple is open sourcing Swift Build

38 comments

·February 1, 2025

tux3

The goal for Swift should (and seems) to be to gradually separate itself from XCode, which is holding it back from its ambitions.

XCode has been compared to many things, but at 3.1 stars on the App store, one must find that it is still slightly overrated.

dlachausse

Swift hasn’t required Xcode for several years now. It has robust command line tooling and a VSCode plugin.

https://www.swift.org/documentation/articles/getting-started...

airstrike

Despite being terrible, the last time I checked, the experience in Xcode was somehow still meaningfully better than with the VSCode plugin

rescripting

What don’t you like about the VSCode plugin?

tux3

I believe it still does at least for iOS, or it did last time I checked (for a Swift library I was writing).

plorkyeran

Building Swift code for iOS without going through xcodebuild is sort of obnoxious but is possible. You do need to have a copy of Xcode installed regardless of programming language simply because the iOS SDKs aren't distributed separately.

jitl

Hence this announcement is great, since it seems to say they’re (going to?) support building GUI apps with SwiftPM and/or the newly open sourced build tool.

uhura

I believe that this long game of Swift being "good for everything" but "better for Apple platforms" will be detrimental to the language. This does not help the language nor seems to bring more people to the ecosystem.

Competitors seems to have a combination of: - Being more open-source - Have more contributors - Have a narrower scope

Maybe they should consider open sourcing all the tooling (like Xcode) otherwise the gap will only grow over time when compared to other languages.

picafrost

Swift is a nice language. I'm glad to see it being released from the clutches of Apple. I can only imagine how large of a task this is. I hope some day to be able to use it. The last time I tried a cross-platform project with it I switched languages due to `URLSession.shared.data` (a network request) being unable to compile on Linux.

isodev

Is it really being released? Although some parts of the language and build chains are technically open source (as in, you can see the code), the project is still completely controlled by Apple at the top.

cvwright

They have also been working on a completely open source version of the Foundation library for use on Linux and other platforms. (IIRC the URLSession type is part of Foundation, as are many core building blocks that you need for making a real application.)

sgt

Is Swift actually serious about embedded?

timsneath

Of course! Tons of examples here: https://github.com/apple/swift-embedded-examples

At WWDC24, we shared a session on embedded Swift, which is available on YouTube: https://www.youtube.com/watch?v=LqxbsADqDI4

More documentation on embedded Swift tooling here: https://github.com/swiftlang/swift/blob/main/docs/EmbeddedSw...

(Disclosure: I work at Apple.)

nozzlegear

Thanks for that link to the examples repo. I had just started looking into embedded Swift for an rp2350 project a couple days ago, but (being a novice in embedded hardware/microcontrollers) I got the impression from the Swift website that the device wasn't supported yet and I'd need an rp2040 instead. It looks like there's an example project for the rp2350 in that repo though, so I'm going to be playing with this tonight!

sgt

Swift is unbelievably cool but I wonder about using Swift for an embedded project as opposed to just C or with FreeRTOS for a more capable system. Is interoperability possible - as in FreeRTOS+swift?

aseipp

For the most part, yes, it should be very achievable. Embedded Swift basically just produces an object file that looks like any object file from a C compiler. The objects mostly rely on very basic primitives like malloc/memcpy so it's pretty freestanding (you can turn off allocations, too). It also has very good support for importing C headers into Swift code so you can interop easily.

Probably the biggest roadbump for something like FreeRTOS is the asynchronous support though. Embedded Swift's async support is still extremely rudimentary and I didn't find much about how to extend it/attach it to other control loops. I think it only supports single-threaded execution right now as well.

pjmlp

Why should it not, one of the design goals of Swift as C, Objective-C and C++ replacement was painless interop with those languages.

Thus it is more an issue of Swift embedded toolchain being able to be used alongside FreeRTOS on the specific hardware target.

robterrell

If you look at the blinking LED sample, it's pulling in the freertos header:

  #include "freertos/FreeRTOS.h"
So presumably yes?

wslh

Wow! I’m really surprised by the ESP32 work here [1]. This looks super interesting! And, personally, unexpected.

This is the kind of thing that makes you want to quit your job and just tinker all day again.

[1] https://github.com/apple/swift-embedded-examples/blob/main/e...

jitl

Although opinions inside Apple about Swift vary, they seem to be investing in low level Swift for embedded, kernel use, and programming the “Secure Enclave” subsystem.

They certainly have many opportunities to use it for headphones, AirTag, flash driver, etc, beyond the very believable but less embedded use in kernel/Secure Enclave.

See also the wwdc session where they propose swift for building smart home thingies https://youtu.be/LqxbsADqDI4?si=KTYWPLdjGgTwK1UB

pjmlp

Yes, one use case is to eventually replace the Safe C dialect Apple uses for iBoot firmware.

dlachausse

Yes, there was an entire WWDC ‘24 talk about it…

https://developer.apple.com/videos/play/wwdc2024/10197

Swift is a great language, but it is unfortunately still held back by the stigma of being perceived as only usable on Apple platforms.

o11c

And until packages are actually shipped for all mainstream distros, the stigma is completely accurate.

No, neither "just install a tarball" nor "just install this docker image" count.

st3fan

Go has been shipping for more than a decade as a .tgz and does not have this stigma at all ...

Anyway, you probably missed the following

https://www.swift.org/install/linux/

I see all major distros there.

But people will probably mention some distro not listed and say the mainstream distro support is a farce. For some reason people have set the bar for Swift incredibly unrealistically high and there will always be something wrong it.

Your loss though. Swift is amazing. Both on MacOS and Linux.

jitl

Distro packaging for programming language ecosystems is so often hopelessly out of date. I’ve never used a distro toolchain or packages to build production software for any language Python’s age or younger.

Outside of C/C++/Fortran pretty much every project I see on Github prefers things like Rustup or Nix for toolchains to navigate around Debian/Ubuntu/RHEL’s “stability” approach.

pjmlp

I remember when all Linux projects used to be install a source tarball and do the configure, make config, make, make install dance.

That hasn't prevented Linux to take over most UNIX workloads.

rkunde

This is great, if for no other reason that it will give people the ability to debug build issues on their own and get access to fixes without having to wait for the next Xcode release.

MetallicCloud

I wish they would stop adding anything to the language and document what they have. I constantly need to reverse engineer how things work. For example, I just had to integrate AccessorySetupKit and the docs are laughable.

bhokbah

AccessorySetupKit is an Apple framework, not part of swift

layer8

> a foundational step in this new chapter of Swift build technologies

The corporate language throughout that post is pretty cringe. It seems so unnecessary.

sunnybeetroot

Doesn’t seem corporate at all:

Foundation: a first important step Chapter: the next stage of Swift technologies: it is a technology

jpeg_hero

Can I cut and paste a Core Data Model that my LLM generated?