These some of my points (and probably opinions) after seeing Apple WWDC Video "408 Swift Playground"

What are Playgrounds:

  • File wrapper that contains swift code
  • And resources embeded in project or found in system
  • Contains a time line that provide visualization

In order to see more output from a playground the assistant view contains usefull information:
- Such as time line - Console output - History of values

What are playground used for

  • Learning swift
  • Teach programming to begginers
  • Helps in developing algorithms
  • Display drawing codes and see it immediatly
  • Processing code such as filters on images
  • Experimentation of any type, such as new api, new design, etc...

Result view

the result view side bar displays:
- Values of strings, int, doubles, floats - Attributed strings - Colors - Images - Cocoa and Cocoa touch views - URLS - Bezier paths - Classes and Structs


Contins utilities for enhancing playground (Only for osx)
- Manually capture values - Custom QuickLook - Show views live - Extending execution

Manually capture values

Helps to aggregate multiple items inside one timeline item

XCPCaptureValue (Data, "String Identifier")
Custom Quicklook Support

Allows to visualize subclasses of NSObject, by implementing debugQuickLookObject,

debugQuickLookObject can return: - String - Color - Bezier path - Image

class Test : NSObject {
  func debugQuickLookObject () -> AnyObject? {
    return "Test String"

//Will print Test String
var t = Test()
Show views live

Draw live views in the result area (NSView Only), For UIView it only displays the view without animations,

This is be done by calling XCPShowView on each frame

XCPShowView("uniqe view id", view)
Extending execution

Normally playground stops after top level finish, by calling XCPSetExecutionShouldContinueIndefinitely the execution could continue

This can be used for testing Network and other Async tasks

Playground Limitation

  • Never use it for performance, since execution will be spent mostly on parsing the lines and showing the result
  • Cannot be used for user interaction
  • Playground only supports simulator and not actual device
  • Playground cannot import user custom libraries and frameworks, it can only access system libraries and frameworks