<div dir="ltr">Hi,<div><br></div><div>Ayaka Nonaka gave a talk[1] about basic scripting[2] support in Swift. <br></div><div><br></div><div>The gist of the idea is to use <span class="inbox-pl-c" style="box-sizing:border-box;color:rgb(150,152,150);font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:12px;white-space:pre">#!</span><span style="color:rgb(150,152,150);font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:12px;white-space:pre">/usr/bin/env xcrun swift</span></div><div><br></div><div>Therefor it seems the basic building blocks for allowing a swift file to &quot;execute itself&quot; are always laid out and proved to be applicable. </div><div><br></div><div>What&#39;s missing IMHO is a better support for dependencies, the suggested solutions in the talk are using the -F for including frameworks that were built using Carthage or CocoaPods. That&#39;s not idle because a script I think should be self contained, meaning that you can &quot;just run it&quot; and it works. </div><div><br></div><div>So, I&#39;m wondering what if it was possible to include the dependencies inside the swift file itself? Probably using the same format as the Package.swift syntax. The the swift binary would &quot;detect&quot; that it&#39;s a self contained file, it could make this distinction because <span style="font-family:&#39;anonymous pro&#39;;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)">import</span><span style="font-family:&#39;anonymous pro&#39;;font-size:11px;font-variant-ligatures:no-common-ligatures"> PackageDescription </span>is defined by the user.</div><div><span style="font-family:&#39;anonymous pro&#39;;font-size:11px;font-variant-ligatures:no-common-ligatures"><br></span></div><div>Then it would follow a 3 step process:</div><div>1. It should download and build the dependencies</div><div>2. then compile the code inside the file</div><div>3. and then run it. </div><div><br></div><div>Having everything happening behind the scenes, so the &quot;script user&quot; simply calls <font face="monospace">./MyScript.swift</font> or <font face="monospace">swift MyScript.swift</font> and it &quot;just works&quot;. </div><div><br></div><div>Wondering what the community thinks.</div><div><br></div><div>[1] <a href="https://realm.io/news/swift-scripting/">https://realm.io/news/swift-scripting/</a></div><div>[2] <a href="https://github.com/ayanonagon/talks/tree/master/2015-swiftsummit/2">https://github.com/ayanonagon/talks/tree/master/2015-swiftsummit/2</a></div></div>