The current state of Swift for Server and Linux

I gather this is unavoidable with regards to private Apple frameworks. Without Apple doing it, the best other developers could do is attempt to match the full API of Apple specific frameworks and playing catch trying to sync with the latest updates. As far as I can tell, unless Apple open sources their private frameworks, the best that could be done is for Apple to do like they did with Swift Crypto, where it automatically forwards to Apple's internal framework on macOS and iOS and provides a native implementation on other platforms, all while being maintained by them. Nevertheless, I feel like Apple is increasingly expanding the number of packages available for Swift that work independently of the operating system, which should subsume this specific issue. I should say though that most of the packages that don't depend on Apple's internal frameworks should work on all OSs supported by Swift, especially the server oriented ones! What frameworks specific to Apple's platforms would you like/expect to see available on Linux that would currently require the if #else dance?

I checked out the article and it does seem very reliant on SwiftUI for the examples and explanations though, which would be a set back to anyone not familiar with it such as people coming to Swift from outside the Apple ecosystem. I am not saying I expect Paul Hudson to write articles that have no mention of Apple specific APIs, just that the OP does still have a very valid point in my opinion.

I haven't experimented with Swift on Linux in some time, but if you read some of the other replies above, it seems that Visual Studio does have plug-ins available for Swift development and that apparently they work pretty well. Sourcekit-LSP is a language server being developed for exactly this use case of enabling, as much as possible, the same experience that you have with Swift in Xcode, but for any other IDEs/editors in whatever operating system it can be compiled to (I may be wrong but I think Xcode uses it internally? or at least I think that is the plan).
You say you are not expecting much from Visual Studio support based on what you read here, is there a reason for that? Like, are there features you expect not to work because they weren't mentioned in the previous replies? This could be really good feedback to give, in case those features are not available already.

The rest of what you wrote about Apple not really being that interested in Swift working well on the server I think is misguided. I think they are investing a lot in it, it might just not be visible enough in this forum or elsewhere. I'm pretty sure I read somewhere they are using Swift on the server internally, so they should be invested in it. Last year they announced support for several new Linux based operating systems for Swift. There is the Swift Server Working Group (SSWG) that is trying to manage this space, SwiftNIO and a bunch of other packages developed specifically for use in server environments as mentioned by @hassila above and I think Amazon is supporting it too (they were (partially?) behind bringing swift support to Amazon Linux 2 if I'm not wrong, and the Swift AWS Lambda Runtime package). I think the folks who work with Swift on the server the most usually hangout in other channels where they talk more casually, like on a Discord or Slack channel. Maybe someone can share a link to those channels here.

Overall I think Swift on the server is on a good path. Note though that I'm not saying that there is nothing to improve — if anything the projects mentioned here could become more visible, "official" tutorials and guides should become available as well (I'm pretty sure the SSWG is in the midst of tackling this) and other improvements should definitely be made.

I think (almost?) everything in the Swift standard library is available on Linux. Foundation is where there are some unimplemented APIs or diferences in behaviour. A random number generator is also one of the APIs from the standard library, so it is available on all supported platforms. Hopefully this was the one you found, although I would have thought searching in the documentation first would have yielded results sooner and with less hassle than looking for it elsewhere on the internet or through a tutorial program for the iPhone.

I still think it is important to have these conversations so we can better understand where people are coming from and how we can make it easier for them to get started with Swift whether it is on the server, on macOS, on iOS, on Android, on Windows, on the web (SwiftWASM), on embedded devices, or on any future platforms that become available.

7 Likes