Xcode Playground

An Xcode Playground is a "temporary scratchpad or sandbox" mini-project under Apple's Xcode development environment for creating apps for OS X and iOS. It is actually a subdirectory (folder), in the manner of the OS X bundle file. It is used for experimenting with programming constructs in the Swift language, and was added to Xcode along with that language in 2014.

Swift is a programming language with a smaller amount of required boilerplate code and mandatory complex structure than other languages (including Objective-C, which was previously the primary language of OS X and iOS development), so that it is feasible to try single lines of program code one at a time, in an interpreter-style environment (as was typical in BASIC a long time ago, and is also the case with Python now). This is the function of an Xcode Playground, which works like a cross between such an interpreter and a full-screen program editor; you can see the outcome of program lines immediately, but can also go back and edit other lines further up the page (which will affect the outcome of subsequent lines as well).

Contents of bundle
Typical contents are:


 * contents.xcplayground: An XML file showing the relationship and purpose of other files in the playground
 * section-1.swift: The Swift program code that the user has typed in.
 * timeline.xctimeline: Another XML file.

Links and references

 * Exploring and Evaluating Swift Code in a Playground