[GSoC 2021] Scripting in Swift

Hello! I’m YR Chen from University of Science and Technology of China, majoring in Computer Science. I’ve been using Swift for a long time (mostly in server side) and starting last year I began to contribute codes to Swift and other projects. My works include a simple Swift toolchain management script for Linux, and a forked version of swift-aws-lambda-runtime for Tencent SCF. I’m also implementing Windows support for swift-driver now.

I’m very interested in the project idea of adding SwiftPM support in Swift scripts. I’ve kept tracking on the SwiftPM support for Swift scripts thread since nearly a year ago (and also left a comment lol), and I’m really excited that it’s going to be picked up. Here’s my plan for making it an official evolution proposal:

  • Draft a proposal based on the original one, and discuss with community members on the API design and working structure;
  • Integrate SwiftPM support for scripts in SwiftDriver;
  • Linux and macOS are the first target platforms for this proposal;
  • Before the proposal is accepted, this feature will be available behind a flag;
  • If possible, it should also be integrated into Swift REPL and SourceKit.

Currently, I plan to add the package parsing ability to Swift’s parser. SwiftDriver retrieves the package information from the frontend, and then hands it over to SwiftPM. SwiftPM will gain the ability of caching the build (and probably the script itself) and managing the cache. What do you think about this idea? @abertelrud @tomerd


Also @NeoNacho :slight_smile:

This is a very exciting feature and much needed. Good luck!


Thank you! I just failed to find his ID :cry:

1 Like

I'm looking forward to it too! Really excited and honored if I can participate.

1 Like

thank you @stevapple for reaching out, getting a proposal out to discuss the design would be a great step forward, looking forward to see what you come up with -- this would be a great addition to the Swift ecosystem


I’ll try it out. Thanks for your instruction!

A good approach is to write a more light-weight version of the proposal and pitch that, then develop it to a full proposal with sample implementation once the pitch converges

1 Like

The revised proposal is finally posted to the forum! Here are a few highlights for the new parts:

  • The new swift-script tool for managing scripts and caches;
  • Design details on how a script is built and run;
  • Some alternative designs.

Welcome to check it out! @abertelrud @NeoNacho @tomerd


I’d like to make it clear here that I’m not going to implement the whole proposal during GSoC.

I plan to work out a suitable working logic and implement the key function (swift script run, I suppose) as for the GSoC proposal. The current SE proposal is only a draft that provides more details than the original one, and hopefully it will be improved and finalized though community discussions (and the GSoC practice) over time.

P.S. Forgive my awkward English :joy:

Having a fully fledged proposal that can be implemented in multiple steps make total sense. The design should allow for such steps, making sure that we can build something useful, even if small, as part of the GSoC project

1 Like

I think the basic swift-script run <file> demo will meet the GSoC requirements. For the current proposal, this involves parsing the attributes, dumping the results into a JSON file (frontend), searching the cache, resolving the dependencies, building and running the code (SwiftPM).

Based on a successful demonstration, we can then implement the swift-script toolset (breaking into multiple parts), and finally other integrations.


Update on GSoC goals:

The goal for GSoC is some kind of proof-of-concept and is expected to be the foundation of a full implementation of this feature. The outcome is expected to be a prototype of the new swift-script tool, which has a limited set of basic operations implemented like run and reset. There will also be a new flag for Swift Driver which enables a shortcut to the feature through swift command.

Really excited to participate!

1 Like
Terms of Service

Privacy Policy

Cookie Policy