top | item 42899703

Apple is open sourcing Swift Build

612 points| dayanruben | 1 year ago |swift.org

283 comments

order
[+] uhura|1 year ago|reply
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.

[+] alain_gilbert|1 year ago|reply
Swift is a really cool language.

But one thing that blows my mind is that if you ever encounter an "index out of range" error, the (massive) error message that you get doesn't tell you anything about where this error occurred... no line number... no nothing...

    let a = [1]
    print(a[1])
Is all you have to do to reproduce the error.

The error looks something like that https://pastebin.com/MQV82SaR

And gives you no useful information as to how it happened or how to fix it.

compare that with Golang which tells you, it happened in main.go at line 4.

    panic: runtime error: index out of range [1] with length 1
    
    goroutine 1 [running]:
    main.main()
     /Users/username/main.go:4 +0x15
    exit status 2
EDIT: with the LLVM_SYMBOLIZER_PATH set https://pastebin.com/8M9Dbrgj this doesn't provide anything useful either.
[+] mojuba|1 year ago|reply
You have a stack dump, which means you will get all the information if you symbolicate your crash report. Xcode can do it for you automatically, but some manual methods also exist.
[+] g0ld3nrati0|1 year ago|reply
I am getting proper error feedback,

``` swift_hello_main + 322 in swift-hello at /home/fermi/Documents/temp/swift-hello/Sources/main.swift:64:8

    62│
    63│ let a = [1]
    64│ print(a[1])
      │        ▲
    65│
```
[+] Pesthuf|1 year ago|reply
What if you follow the advice here

>Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):

?

[+] saagarjha|1 year ago|reply
The Swift REPL sucks for this. I would suggest you compile to a binary and use your normal debugging tools.
[+] jitl|1 year ago|reply
Swift outside of Xcode is a bit rough around the edges, I think because more attention goes into making Xcode friendly. I opened Xcode, made a new playground, and hit run, the code crashes and highlights the line where the error occurred in red. Not to excuse Swift's jankyness, just saying that the kind of default experience is more an IDE-first design compared to Go's very good unix-first design.

https://monosnap.com/file/qhlwD6aXUW5bcl3TV5lPmKFDgjWDtD

[+] AdrianEGraphene|1 year ago|reply
Thanks for reminding me of why I shy away from Swift and dove into the arms of Kotlin Multiplatform.
[+] compootr|1 year ago|reply
Verbosity. That's..... yap-ple!
[+] aristofun|1 year ago|reply
Swift itself is a great piece of tech.

But it is doomed to fail as a general widely adopted language unless apple makes few critical moves including open sourcing everything including XCode, providing support for 3d party IDE developers (because xcode is terrible), creating decent package manager, adopting testing as first class citizen etc.

There is just no economical sense for anyone to invest in swift until all the above (and some more) is done.

[+] easeout|1 year ago|reply
For what it's worth, they ship a solid VS Code extension and LSP. Their swift-testing package is the new open source and cross-platform successor to XCTest. The same can be said of swift-foundation as compared to Foundation.

The path they've chosen is not to open source Xcode, but to move the things Swift needs on all platforms to the Swift language project and common implementations.

Personally I think the main problem with the language, besides Apple's earned poor reputation in FOSS circles, is the compile times. In the source-stable era of the language I'm not sure how they can really be fixed to the degree I'd be happy with.

[+] fastball|1 year ago|reply
Your wishlist seems midly contradictory. Why does Apple need to open-source XCode if they also provide support for 3rd party IDEs (which they already do, btw)? Also what do you not like about cocoapods for package management?

Plenty of people make an incredible amount of money building apps in Swift, so your last sentence is just wrong.

[+] isodev|1 year ago|reply
And make it possible to run binaries on macOS/iOS etc without a mandatory subscription and US export controls. Without notarisation, anything made with Swift is practically unusable on Apple OSs
[+] krupan|1 year ago|reply
The discussion here reminds me so much of early C# days. It was being touted as open source and cross platform back then, and Microsoft even hired a top GNOME developer to port it to Linux and GNOME was going to be rewritten in C#. It was going to be amazing. Never quite panned out.
[+] kelnos|1 year ago|reply
I think you might have the history mixed up a bit. The Mono project started without Microsoft's involvement (and they were probably even annoyed by it at the time).

GNOME was betting on their own Vala language, which is still a thing, but never really gained much traction.

Eventually Microsoft bought Mono during their embrace of open source.

[+] pjmlp|1 year ago|reply
Microsoft never had anything to do with that with nice story full of butterflies.

The only UNIX Microsoft has ever supported during pre-Satya days, was Rotor for FreeBSD, nothing else.

Mono and DotGNU had nothing to do with Microsoft until Xamarin acquisition.

[+] WuxiFingerHold|1 year ago|reply
> Never quite panned out.

I don't know what you're talking about, honestly. Maybe you're many years behind the current state of affairs.

.NET (core) is a very real thing. A extremely successful and powerful multi platform framework.

[+] raydev|1 year ago|reply
> Microsoft even hired a top GNOME developer to port it to Linux and GNOME was going to be rewritten in C#

Do you have a source for the GNOME C# claim? I can't find one.

[+] homarp|1 year ago|reply
do you remember who was the 'top GNOME developer'?
[+] tux3|1 year ago|reply
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.

[+] de_aztec|1 year ago|reply
from the article:

> With this release, SwiftPM now has the opportunity to offer a unified build execution engine across all platforms.

this is what the big deal is. it might not achieve much on its own immediately, but this is the key to build a truly multiplatform ecosystem of libraries, tools and applications in Swift. we should expect to see more of that soon.

[+] ustad|1 year ago|reply
Apple’s software decisions over the last 15 years have created significant friction for developers trying to build on their platforms. Apple’s approach to software development has felt like it’s prioritizing business interests over the ease and flexibility that developers need to build high-quality, useful software.
[+] picafrost|1 year ago|reply
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|1 year ago|reply
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.
[+] sgt|1 year ago|reply
Is Swift actually serious about embedded?
[+] jitl|1 year ago|reply
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|1 year ago|reply
Yes, one use case is to eventually replace the Safe C dialect Apple uses for iBoot firmware.
[+] isodev|1 year ago|reply
Apple probably has use cases for this and they’re bringing it into the open as a nice marketing thing. I wouldn’t count on long term support or compatibility beyond current priorities for Apple (same as their other SDKs for iOS, macOS etc).
[+] easeout|1 year ago|reply
Have a look at today's Swift track FOSDEM talks.
[+] rkunde|1 year ago|reply
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.
[+] layer8|1 year ago|reply
> a foundational step in this new chapter of Swift build technologies

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

[+] paul_e_warner|1 year ago|reply
Reading this it’s not clear - how well integrated is swift build with swift’s tooling and language server? I know the language server has been open source for a while now. Having them be separate seems like it would create issues with duplicate code.
[+] msk-lywenn|1 year ago|reply
The article doesn't mention the differences with current swift package manager build system. The repository doesn't mention it either, just saying that swiftpm can use the new build system by adding an argument. Anybody does what does this actually changes? Does it improve something for non-Apple platforms?
[+] seanvelasco|1 year ago|reply
i'd love to be able to build web servers in Swift. the language is such a joy to use
[+] easeout|1 year ago|reply
Check out Vapor
[+] bla3|1 year ago|reply
I wish swift was built against normal LLVM instead of against Apple's fork of it.
[+] MetallicCloud|1 year ago|reply
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|1 year ago|reply
AccessorySetupKit is an Apple framework, not part of swift