20 ms·
Apple is open sourcing Swift Build
- sgt 2y agoIs Swift actually serious about embedded?
- timsneath 2y agoOf course! Tons of examples here: https://github.com/apple/swift-embedded-examples 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 https://www.youtube.com/watch?v=LqxbsADqDI4 More documentation on embedded Swift tooling here: https://github.com/swiftlang/swift/blob/main/docs/EmbeddedSwift/UserManual.md https://github.com/swiftlang/swift/blob/main/docs/EmbeddedSw... (Disclosure: I work at Apple.)
- wslh 2y agoWow! 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/esp32-led-blink-sdk/main/Main.swift https://github.com/apple/swift-embedded-examples/blob/main/e...
- sgt 2y agoSwift 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?
- pjmlp 2y agoWhy 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.
- josteink 2y ago> Why should it not, one of the design goals of Swift as C, Objective-C and C++ replacement was painless interop with those languages. This is actually a very good quality. I'm exploiting that for all it's worth in a job project where I'm gradually (file by file) converting a legacy codebase from Objective-C to Swift. Providing an exit-strategy for Objective-C is good enough reason for me to at least have a basic working knowledge of the language.
- aseipp 2y agoFor 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.
- robterrell 2y agoIf you look at the blinking LED sample, it's pulling in the freertos header: #include "freertos/FreeRTOS.h" So presumably yes?
- nozzlegear 2y agoThanks 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!
- elforce002 2y agoHi Tim. I liked your work with dart/flutter. Are you guys working on overhauling Xcode? The DX is atrocious.
- sgt 2y agoDid something happen with Xcode? I used it around 5 years ago, and it was pretty good and fast. I don't think it had dark mode but that's not too important to me.
- cosmic_cheese 2y agoXcode is fine as long as you skip Interface Builder and make a point to keep your SwiftUI views lightweight. For the latter my rule of thumb is to try to cap nesting in any given view at 3 levels and to break code out into new components for anything deeper, which is a good practice since readability starts declining steeply past 2-3 levels deep anyway. It doesn’t have all the whizbang features of Jetbrains IDEs, but my experience is that those sorts of features only work correctly sometimes and can be as much of a hindrance as they are a help.
- seviu 2y agoNo refactoring tools, lack of autocomplete, having multiple targets break compilation, errors in the ui, crashes running unit tests, it freaks out when switching git branches, spm can’t handle proxy servers, never ending indexing… List goes on and on. Xcode used to be good at around version 3. Everything that came after that has been disastrous. Meanwhile Android Studio or VS Syudio are tools which are a joy to use and are built to help you and not to be constantly on your way Fact is Apple should do like Google and admit there are better ides out there
- andrekandre 2y ago> Xcode used to be good at around version 3. before the merging of interface builder into xcode: it never recovered...
- frizlab 2y ago
- QuinnyPig 2y agoEncountering an Apple employee in the wild is like spotting a unicorn.
- _mlbt 2y agoYes, there was an entire WWDC ‘24 talk about it… https://developer.apple.com/videos/play/wwdc2024/10197 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 2y agoAnd 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.
- timsneath 2y agoWorking on it: https://github.com/swiftlang/swiftly?tab=readme-ov-file https://github.com/swiftlang/swiftly?tab=readme-ov-file
- Terretta 2y agoBringing synopsis here for those who may not click: swiftly is a CLI tool for installing, managing, and switching between Swift toolchains, written in Swift. swiftly itself is designed to be extremely easy to install and get running, and its command interface is intended to be flexible while also being simple to use. The overall experience is inspired by and meant to feel reminiscent of the Rust toolchain manager rustup.
- jitl 2y agoDistro 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.
- o11c 2y ago
- jitl 2y agoAlthough 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 https://youtu.be/LqxbsADqDI4?si=KTYWPLdjGgTwK1UB
- pjmlp 2y agoYes, one use case is to eventually replace the Safe C dialect Apple uses for iBoot firmware.
- isodev 2y agoApple 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 2y agoHave a look at today's Swift track FOSDEM talks.
- tux3 2y agoThe 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.
- _mlbt 2y agoSwift 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-with-vscode-swift.html https://www.swift.org/documentation/articles/getting-started...
- airstrike 2y agoDespite being terrible, the last time I checked, the experience in Xcode was somehow still meaningfully better than with the VSCode plugin
- rescripting 2y agoWhat don’t you like about the VSCode plugin?
- jitl 2y agoFor me it just spins forever and never manages to do any LSP things
- rescripting 2y agoIf you haven’t tried recently I’d give it another go. A lot of work has gone in to the LSP this past year to stabilize it and improve performance.
- myko 2y agoPretty similar to the Xcode experience, then
- picafrost 2y agoSwift 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 2y agoIs 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 2y agoThey 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.)
- deleted 2y ago[deleted]
- st3fan 2y agoYou are wrong about "some parts" - you can browse github.com/swiftlang to find out. About control - serious question: how is this different from for example Rust, Go, Zig or Python? For each of those you can submit a change proposal through an official process and you can submit code changes through a pull request. But also for each of those there is a non-zero chance that a smaller group of people who do governance of the project, the core team or leads or module owners, will either tell you that your proposal or code change is not appropriate or compatible with the project's goals or they will help you to merge it. That is exactly the same for Swift. Why is Apple suddenly a dictator while every other project also has an agenda and strict rules that are being enforced? Is the expectation to just be able to do whatever you want in a project like Swift?
- rkunde 2y agoThis 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 2y ago> 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 2y agoDoesn’t seem corporate at all: Foundation: a first important step Chapter: the next stage of Swift technologies: it is a technology
- myko 2y agoIt is so Apple, though. I can hear Craig's inflection just reading the sentence.
- jpeg_hero 2y agoCan I cut and paste a Core Data Model that my LLM generated?
- MetallicCloud 2y agoI 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 2y agoAccessorySetupKit is an Apple framework, not part of swift
- uhura 2y agoI 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.
- VWWHFSfQ 2y agoI doubt Apple really cares much about competing with other languages, tooling, or platforms when it comes to Swift or Xcode. They have a completely captured audience and ecosystem, and anything beyond that isn’t even a "best effort" — it's more like, "You're welcome to see if it works for you, but don’t bother us if it doesn't."
- st3fan 2y agoI don't know about Xcode, but Swift is open source with an active community so if it doesn't work for you then you can definitely bother the Swift Open-Source project with a pull request or a proposal for a language or tooling improvement. You can also have a discussion on the forums or in the bug tracker with fellow contributors. You can also make the change in your own fork and use that. This is exactly how for example the Rust or Python open source projects work. And like those projects you can look at the Swift proposals and code to see _numerous_ cases where people did bother to bother the team with change requests or directly contributed to those improvements. It is all open source. Check it out.
- dhsysusbsjsi 2y agoScooby doo meme <Open source contributor> “let’s see who you really are”. <pulls off mask>. Apple employee.
- bastardoperator 2y ago
- msk-lywenn 2y agoThe 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?
- jakepetroules 2y ago> Does it improve something for non-Apple platforms? Yes! This will improve the Swift and SwiftPM experience for _all_ platforms. There are a number of goals outlined on our forums post https://forums.swift.org/t/evolving-swiftpm-builds-with-swift-build/77596 https://forums.swift.org/t/evolving-swiftpm-builds-with-swif..., which goes into much more detail.
- krupan 2y agoThe 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.
- homarp 2y agodo you remember who was the 'top GNOME developer'?
- morningcoffee81 2y agomiguel de icaza
- wahnfrieden 2y agoHe is deep into Swift/SwiftUI now
- IshKebab 2y agoProbably talking about Miguel de Icaza. I think his history is wrong though. I don't recall any talk of rewriting GNOME in C# - they were all about their pet language Vala. And Miguel started Mono way before Microsoft made C# cross-platform. At that point they were antagonists.
- tamlin 2y agoMicrosoft had a research version of the CLR called Rotor (2002) that predated Mono (2004). Rotor built for Windows, FreeBSD, and macOs, albeit with a not-very-open license. When Mono came along, the internal position at Microsoft was surprisingly positive. There was a dev slide deck that went into Mono in some depth. And a telling slide that said it wasn't a threat because the performance wasn't competitive at the time. https://en.m.wikipedia.org/wiki/Shared_Source_Common_Language_Infrastructure https://en.m.wikipedia.org/wiki/Shared_Source_Common_Languag... https://en.m.wikipedia.org/wiki/Mono_(software) https://en.m.wikipedia.org/wiki/Mono_(software)
- alain_gilbert 2y agoSwift 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 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 https://pastebin.com/8M9Dbrgj this doesn't provide anything useful either.
- Pesthuf 2y agoWhat 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): ?
- Cyph0n 2y agoWhat if the error was more descriptive out of the box? Unless of course the goal is to just compete with C++ error reporting.
- catgary 2y agoThe goal is to probably avoid duplicating efforts when llvm-symbolize already exists. There’s obviously a snarky comment to make here about Go developers and duplicating efforts.
- deleted 2y ago[deleted]
- alain_gilbert 2y agoIf I follow the advice https://pastebin.com/8M9Dbrgj https://pastebin.com/8M9Dbrgj Not sure how that's any better... I still have no idea that the error occurred on line 2
- 3789 2y ago[flagged]
- deleted 2y ago[deleted]
- paul_e_warner 2y agoReading 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.
- de_aztec 2y agofrom 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.
- walterbell 2y agoDoes this open a path to Swift development without Xcode? Recent discussion of Xcode, https://news.ycombinator.com/item?id=42803290 https://news.ycombinator.com/item?id=42803290
- frizlab 2y agoThis article is completely wrong. I actually did what the author complained was impossible to do.
- walterbell 2y agoThe article was wrong, but it motivated 100 comments about various issues with Xcode.
- bla3 2y agoI wish swift was built against normal LLVM instead of against Apple's fork of it.
- bartekpacia 2y agoDoes the world need yet another build system? (not sure, just thinking out loud)
- easeout 2y agoThe idea is to end up with one fewer!
- yuyafujimoto 2y agoIt’s too late
- aristofun 2y agoSwift 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 2y agoFor 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 2y agoAre there any LLVM langs that have fast compile times? I think that just kinda comes with the territory of having that IR step + all the optimizations that happen at compile time to help runtime performance.
- easeout 2y agoThat's a good point. I had in mind that there's some regret about the combination of type inference with type-based overloads, due to the search expense it adds to what ought to be straightforward parsing of long expressions.
- fastball 2y agoYeah, I think there are definitely parts of the language design / language features that are going to contribute, but when you need to parse to IR and then compile that to machine code, it seems any features you add that are nice for the developer are going to doubly hurt compile times. You see the same with ARC in swift (or the borrow checker in Rust).
- khana 2y ago[dead]
- seanvelasco 2y agoi'd love to be able to build web servers in Swift. the language is such a joy to use
- easeout 2y agoCheck out Vapor
- Alifatisk 2y agoWasn't Vapor discontinued or do I have a false memory now?
- sbuk 2y agoIt's still active. The last stable release was August/September last year.
- easeout 2y agoKibana was discontinued, maybe you're thinking of that one?
- Alifatisk 2y agoHmmm, I think it was this: IBM announced it was discontinuing its involvement in server-side Swift development, including Kitura Yeah I just mixed up Kitura with Vapor.
- frizlab 2y agoYou already can.
- ustad 2y agoApple’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.
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- Peterthomos 2y ago[dead]
- Kurtcheng 2y ago[dead]