A scripting Swift IDE prototype (demo video)

I love Swift for iOS and macOS apps and I want to use it for everything else on my Mac. So I made a prototype that I call "Swift Light":

I posted a demo video here » https://underplot.com/light

This is not an Xcode alternative — Xcode is obviously aready really good at what it does, also it's first-party and it's free.

Swift Light is an alternative of you having to use scripts from the command line and fall back on weird languages to do so. It could be really good for local automation, experiments, and highly specialized computations like statistical work, graphing, and more.

Please let me know what you think once you've watched the video, I'm curious to get everyone's thoughts! :tada:


Press X to Doubt :P

But seriously, this looks cool. It's seems two steps away from being a modern day Hypercard.


I like that modifying main's return type modifies the result type in
the sidebar. Do you use SourceKit to fetch the return type?

I am curious about the implementation. Do you compile the program to
an executable, run it, and capture the output? Or do you compile the
program to a loadable object, load the object, look up symbol main,
call it, and use the return value?

To access the toolchain, does Swift Light need to run with a lightly
restricted privilege set?


Is it wrong that I’m hoping Apple sherlocks this for the next version of Automator?

Yeah, I have a very simple visitor that grabs all the details of the main function and rebuilds the IDE UI dynamically. Regarding the execution - I've considered both approaches. Currently I'm not concerned with performance so I'm compiling and running a binary to capture the output but of course it'll be much more neat to compile, dlopen and invoke main - the issue is if main's signature is different each time you dlopen, how do you invoke it :thinking:

1 Like

Apple has their own priorities, not sure if this kind of scripting is one of them...

This looks nice; I would use something like this, for sure.

Currently if I need to run a code snippet, I use Xcode Playgrounds, but they're really unstable. They start off working as you'd expect, but after a while they just stop executing no matter how many times you click the "play" button :man_shrugging:

One thing that would be nice is package support. We've talked about adding this to Swift scripts in the past, but as of now nothing has landed AFAIK.

Also, I noticed that the code-completion popup doesn't include documentation snippets. That would be another nice thing to add, together with Xcode-style quick help popups or some kind of documentation viewer sidebar.

But yeah, looks really nice :+1:


Looks real nice. Currently I use Coderunner to run my swift scripts, it works pretty well, but a dedicated UI would be even cooler.


I had a chance to come back to this project and used today to add testing:

  • import XCTest to enable the testing inspector
  • add test functions anywhere in the source file
  • inspector shows up success/failed tests
  • there's a stopwatch while running each test so slow outliers are highlighted in red
  • diagnostics in the source editor

I posted a short video here: https://twitter.com/icanzilb/status/1486728440350789647


Took few more hours today and added an instrumentation pane that allows you to select some source in the editor and time it:

I posted a short video here: https://twitter.com/icanzilb/status/1487049835916283905


this looks really interesting, any plans to support linux? i suspect this is where you will find most of your audience, since we don’t really have a lot of good editors for swift on linux

I've done plenty of Swift for Linux on my mac via Docker and that worked fine for me so I'm honestly wondering how big of an audience are we talking about? I haven't read much about Linux on the desktop for a while so I'm not sure if there is a real customer pool to develop for?

Today I took some time to build a demo of how Swift scripting could look like if the IDE supports it — :clapper: here's the video summary: https://twitter.com/icanzilb/status/1488921680667983880