๐ŸŸ Arena: Explore SPM packages with ease

The Swift Package Manager (SPM) made a big leap forward last summer when it gained Xcode integration. While it was quite feasible to use it for Swift projects before, being able to manage packages via Xcode made it so much easier and removed almost all of the friction when dealing with Package.swift files.

One area that is still a bit lacking, however, is the ease with which you can bring SPM packages into Swift playgrounds.

With Arena, this is now as simple as copying a Github URL. Just run

arena https://github.com/finestructure/Gala

and Arena will assemble an Xcode workspace with a playground ready to go and explore the package you are interested in trying out. (Find out more about Gala here.)

Perhaps you want to give Alamofire 5.0 a try before upgrading? Just run

arena https://github.com/Alamofire/Alamofire@from:5.0.0

and youโ€™re good to go:

Playgrounds are a great way to explore Swift and Arena now makes it a breeze to extend that experimentation to SPM packages.

Try out Swiftโ€™s new ArgumentParser library

arena https://github.com/apple/swift-argument-parser

or give Dave DeLongโ€™s Time library a spin:

arena https://github.com/davedelong/time

Itโ€™s dead simple to get going with Arena and playgrounds.

Arena supports the same version specifications you can use in Package.swift so you can easily pick a particular version, version range, branch, or even revision. Head over to Arenaโ€™s Github repository to see a list of examples (and give it a โญ๏ธ while youโ€™re there ๐Ÿ™‚).

Create Playground Books for Swift Playgrounds

In February, Apple released Swift Playgrounds for Mac and if you prefer the app over Xcode playgrounds, Arena can create Playground Books which can be imported into Swift Playgrounds.

And as a bonus, these Playground Books can sync over to your iOS devices where you can continue to work on them.

This feature is experimental for the moment. It requires that the SPM packages you are trying out support iOS and it does not yet resolve transitive dependencies. However it should allow you to try out many packages using the same playground file on your Mac and iOS device.

You can create a Playground Book by passing the --book parameter to the arena command:

arena https://github.com/finestructure/Gala --book

Run

open Arena-Playground/Arena-Playground.playgroundbook

to open and import the Playground Book. And it works on your iOS device as well:

Install via Homebrew or Mint

Arena is easy to install via Homebrew

brew install finestructure/tap/arena

or Mint

mint install finestructure/arena

So you are really at most two command line invocations away from trying out an SPM package in a playground.

Arena has already helped me a lot evaluating and exploring packages and I hope it does for you, too.

Do you have questions or suggestions? Please get in touch via Twitter or email!