For the ones who missed it last November, I’ve been playing with a Swift IDE prototype which allows you to easily develop Swift scripts for the mac.

I shared a video showcase demoing how the tight integration of the IDE with the toolchain allows you to write scripts, capture inputs and outputs, and all that in a neat SwiftUI interface:

More than anything else I worked on this to explore and demonstrate how easily I can build powerful Swift tools. To build the IDE prototype only took a few weeks of on-and-off work.

For personal reasons I couldn’t do much since November but last week I had a few days of free time and worked on three cool concepts I’d like to show you.

1. Testing scripts

Firstly, I took few hours to add a test runner and live tweeted about it. The feature allows you to:

  • add tests anywhere in the script, they are discovered automatically as you type
  • automatically enable the test inspector when you import XCTest
  • run tests with one click in the inspector panel
  • measure tests' duration and highlight any slow outliers

You can see all of these in action in the embedded video player below:

2. Instrumenting code

The next day, I thought it’d be fun to add yet another build pipeline โ€” for instrumenting. In the past I often needed to time (i.e. clock the duration of) random pieces of code, so I went forward and added that feature right in the UI:

  • you can select a part of your source code directly in the editor
  • when you run the project for profiling you see the execution duration
  • if the code runs multiple times, you get a list of all durations
  • the results are displayed inside the code editor alongside the code in question

You can see all of these in action in the embedded video player below:

3. Extending Swift

Finally, I worked on extending Swift from within the IDE. I really believe it could be very beneficial for the language if there was an easy way to extend it with new functionality so everyone could build features.

So, I took few hours to add a freeze command to Swift that freezes a variable to prevent you from mutating it in a given context:

  • use freeze(myVariable,...) { ... } anywhere in your code
  • list one or more variables to freeze (including class instances)
  • you can nest frozen contexts for fine-grained control
  • get a compile error if you try modifying a frozen variable

You can see all of these in action in the embedded video player below:

Needless to say, this was incredibly satisfying to work on (especially given how quickly it was implemented) because it made me feel a bit more in control of what Swift could do for me :)

What’s next for Swift Light

At this point the prototype has a solid infrastructure that allows me to add faetures in mere hours as the key elements like the editor, diagnostics, toolchain and custom panels are playing very well together.

On the other hand, there hasn’t been too much of a reaction to the videos and the information I been sharing. I feel like I’ve done plenty to share on all channels I have access to but that’s barely moved the needle โ€” no newsletter shared about this, I couldn’t engage in a meaningful discussion about this publicly, and few people even shamed an Xcode alternative IDE in private.

Maybe a bigger company could launch this to a success and effectively spark the interest in a powerful Swift IDE(s) for specialized tasks as I imagine it. But I don’t think I can do much with the limited reach I have on my own.

Do you have any thoughts about Swift Light? Know a company that could be interested in it?

Reach out at https://twitter.com/icanzilb or find me in one of the dev Slacks like https://combinecommunity.slack.com


Where to go from here?

If you’d like to support me, get my book on Swift Concurrency:

ยป swiftconcurrencybook.com ยซ

Interested in discussing the new async/await Swift syntax and concurrency? Hit me up on twitter at https://twitter.com/icanzilb.