Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
As long as they don’t rely on Apple platform specific features; The Swift Package Manager works on Linux through a CLI I believe.

Old thread, but I wanted to say this is completely true. I’ve compiled Vapor on a Raspberry Pi, and outside a few bugs with Foundation, it’s generally been equivalent to running on macOS. You aren’t going to have built-in libraries beyond Foundation and Dispatch, but those are both very useful starting points for services and command-line explorations of the language.

And those bugs are getting fixed, too. I tend to use a Mac to build/unit test and do final builds on Linux. It is possible to be fairly cross-platform for CLI things.

I’ve been using it for a “live“ project for over a year to run Swift on a Raspberry Pi, including hardware control. Works fine, and I can leverage libraries that exist As long as they don’t depend on AppKit/UIKit and the like.
 
You aren’t going to have built-in libraries beyond Foundation and Dispatch, but those are both very useful starting points for services and command-line explorations of the language.

Just want to add that you have Swift Foundation available, which is not! the same as macOS' Foundation or CLFoundation. It is very similar, and for some things there may be no difference at all, but do not expect them to be 1:1 identical to each other.
 
Just want to add that you have Swift Foundation available, which is not! the same as macOS' Foundation or CLFoundation. It is very similar, and for some things there may be no difference at all, but do not expect them to be 1:1 identical to each other.

You’d be surprised. There’s a decent chunk of CoreFoundation code sitting in the OSS version. One of the issues is that they wanted them to be functionally close enough so it could be leveraged for cross-plat work, so CoreFoundation is partly embedded in it (and the C entry points are callable), with Swift reimplementations for Obj-C code that they can’t port (for obvious reasons).

But yes, they aren’t 1:1 identical any more than it is for for iOS and macOS. Mostly because the Obj-C layer isn’t fully reimplemented.

Differences in behavior are bugs.
 
  • Like
Reactions: casperes1996
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.