Authoring Swift Playgrounds Subscription Feeds

WARNING: Technical content ahead. This one is for those people monkeying around with their own Swift Playgrounds for teaching or just for fun. 

If you, like me, author Swift Playgrounds, you might want to use Apple’s new subscription format to distribute your playgrounds to people. You can visit https://thecodehub.ie/playgrounds/ on an iPad and our first three playgrounds will show up on your device.

Subscribing to Playgrounds
Subscribing to Playgrounds

There are some great tutorials and tips for writing playgrounds out there (Andy Shep has some excellent advice on the subject). In the future I’ll go into how I made the Code Hub Swift Playgrounds, but for now, I have a tip for debugging the feed format.

Creating (and Debugging) a Swift Playground Subscription

With the latest version of Swift Playgrounds, you can create a feed so that your content shows up in the list of playgrounds available to run. That link will give you a bit of insight into the nitty gritty of how you need to format your feed, but for a really clear walk-through it’s worth watching the “Creating Your Own Swift Playground Subscription” session from WWDC this year.

All of which I did, but I really struggled with a feed that just wouldn’t work and presented me with a very generic failure message. So I filed a bug with bugreport.apple.com and waited. In the latest version of Swift Playgrounds you can now go to the preferences for the app (through the System Preferences app) and toggle this little switch:

Authoring Debug Mode
Authoring Debug Mode!

Suddenly I was getting far more useful error messages like this:

Ah ha!
Ah ha!

And that was it! Now, you want to make sure you read through all the keys and acceptable values in the feed format closely. There are quite specific sizes for your thumbnail, preview, and banner images. The content identifier, version, and name in your Manifest.plist must match the values you put in the feed.

The Manifest.plist
The Manifest.plist

But once you’ve taken care of the details, it’ll be a piece of cake for people to install your playgrounds.