Playground Power

There’s a new article for your attention up at the official Swift blog, Literals in Playgrounds:

New in Xcode 7.1 is the ability to embed file, image, and color literals into your playground’s code. Literals are the actual values of your data represented in their native format, directly within the Xcode editor. For instance, there’s no need to type “myImage.jpg” in the editor – just drag your image from the Finder and the actual image will appear in-line with your code. Instead of showing RGB values to indicate color, the playground will render a color swatch. Literals in playgrounds behave similarly to code you would otherwise hand-author in regular Swift code, but are rendered in a much more useful manner…

If you’ve been underutilizing those playground thingys so far, Playground Secrets and Power Tips is literally a great way to get up to speed,


and it’s literally up to the minute:

So what’s new in this edition? I’ve done a back to front update to incorporate all the new XCPlayground features in Xcode 7.1 beta 3: the new liveView feature that can be used with views and view controllers (and the XCPlaygroundLiveViewable protocol that supports rendering arbitrary model objects), the new ways to continue execution and capture values, etc.

Also, you’ve probably noticed the move to Markdown this year for playground documentation and Swift Documentation, but now there’s full documentation over at the mothership:

Markup Formatting Reference

Use markup formatting commands to create rich comments in playgrounds and to document your Swift symbols for Xcode quick help. Commands include page level formatting for headers and other elements, inline formatting, and images. Playground formatting commands enable page navigation as shown in the following figure … Swift symbol documentation adds descriptions to symbol completion and quick help for symbols …

So if you’re using those legacy HeaderDoc conventions, why there’s all you need to level up!

And to finish up, perhaps a potpourri of playground posts of particular perspicuity:

General tips: NSHipster’s XCPlayground and Erica Sadun’s multitudinous tidbits

Performance Testing in Xcode Playgrounds: “playground that has a similar function to the “measurePerformance” function in XCT.”

Core Graphics Tutorial Part 3: Patterns and Playgrounds: “draw it in a Swift Playground, and then copy the code to a UIImageView subclass.” Or, Overlooked playground cool stuff #3: “build, preview, and save the image to disk. Perfect for creating masks and labels.”

Swift-Diagram-Playgrounds: “two different approaches to creating Diagrams as value types.”

Numerical Algorithms using Playgrounds: “solve problems that don’t have an analytic solution.”


Little Bites Of Cocoa:

Xcode 7.3 Beta 2 introduces live interactive playgrounds; Interactive Playgrounds

Gameboard: “Gameboards built in a playground.”

XCTestPlayground: “… a simple implementation of most XCTAssert macros to use in a Playground … I use this to do TDD directly inside a Playground and then move the code as-is inside my test files.”

Using a Core Data Model in Swift Playgrounds

Playground Graphs

How to run your application in Swift playground

Playground driven development in Swift

Developing UIViews in Xcode Playgrounds

Swift playgrounds tips & tricks

Alex | October 8, 2015

Leave a Reply