Use swift-sh.
quips (stands for nothing, I just like the word quip) is like a small shim around Swift Package Manager that allows you to import Swift packages in single Swift files.
I wrote this dumpster fire during my downtime as a Microsoft intern (not on company time though.) As it stands, four years later, there isn't a better way to run single Swift files, and I honestly prefer to study algorithms by writing them in Swift. So I decided to unarchive and re-use this.
Swift Package Manger on either macOS or Linux, Ruby 2.0+.
I prefer Swift's syntax, personally. :)
mkdir -p ~/bin
curl -s https://raw.githubusercontent.com/donn/quips/master/quips.rb > ~/bin/quips
chmod 755 ~/bin/quips
Ensure ~/bin is in path. Or don't.
The syntax is as follows:
@quip ModuleName:"https://example.com/link-to-repository.git":SemanticVersion
As an example. in your Swift source file:
@quip PlayingCard:"https://github.com/apple/example-package-playingcard.git":3.0.0
To make things even shorter, you can also use a GitHub-specific quip:
@quipgh PlayingCard:apple/example-package-playingcard:3.0.0
To run a quips-based Swift file, you need to use the "quips" command to call the script:
quips Example.swift
You can also use quips as a shebang:
// Swift
#!/usr/bin/env quips
# Bash
./Example.swift
The Unlicense. Check 'UNLICENSE'.