Swift, Apple’s new programming language, is rapidly gaining popularity among new and advanced programmers alike. And one of the best ways to learn Swift is through Playgrounds in Xcode.
What Are Swift Playgrounds?
Swift Playgrounds are a environment that allows programmers to try out snippets of code and immediately see the results displayed.
You can create a new Swift Playground by going to File -> New -> Playground. An environment will open and you’ll see the code editor on the left side and a console on the right side where the output is displayed.
Due to the popularity of learning Swift through Playgrounds, Apple is developing an app that’ll allow you to learn and tinker with Swift on an iPad, so you’ll no longer be limited to Xcode. It’s currently in beta and will be released with iOS 10’s final release.
This curated list of 100+ awesome Swift Playgrounds is a great way to learn the Swift programming language and get exposure to different facets of the language.
If you spot any broken links or know of any more Swift Playgrounds that you think should be added to the list, please let me know in the comments section.
- Learning Swift
- Learning Swift: Advanced Topics
- Apple’s Playgrounds
- Playgrounds about Playgrounds
- Algorithms and Data Structures
- UIKit And Graphics
- Playground sets
Some interesting playgrounds to learn Swift
- Learn Swift – 30+ playgrounds that follow the “Language Guide” section of Apple’s Swift book.
- The Swift Programming Language Playgrounds – 40+ playgrounds, one for each chapter of Apple’s Swift book.
- Swift Reference Playground – Reference playground with basic language syntax and examples.
- Swift Worksheets – Learn Swift by reading through and experimenting with playgrounds.
- Swift Crash Course – A Swift crash course, with links explaining the language and a playground for each topic.
- Swift-Introduction – Collection of playgrounds covering various aspect of the Swift language.
- Swift2 by Playgrounds – Learn Swift 2.0 from playgrounds.
- Swift Hack Pack – Collection of playgrounds that teaches Swift.
- SwiftStandardLibraryPlaygrounds – A collection of playground demonstrating the use of the Swift Standard Library.
- MPCS51030 UChicago iOS Course – Playgrounds from the 2015 iOS course of the University of Chicago.
- The Swift Summary Book – A summary of Apple’s Swift language.
- Swifter Tips – Examples for every feature of the Swift language.
Learning Swift: Advanced Topics
Advanced topics, useful once you have mastered the basics of the language
- A Swift Introduction to Core Data – Learn Code Data experimenting directly in this playground.
- Swiftly Typed Resources – A playground showing how Swift makes Strings, Colors, Fonts, Images, etc easier to deal with.
- TDDSwiftPlayground – Demonstration of using Swift Playgrounds in Test Driven Development with XCTest.
- Swift DSL Example – Implementation of a DSL in Swift.
- Swift KVO Closures – Swift KVO playground.
- Swift Data Tutorial – Learn everythig about NSDate.
- Swift And C – Examples about using C with Swift.
- Swift Memory Management – How to avoid retain cycles, from this post.
- Concurrency on iOS – Concurrency and Parallelism in iOS.
- Design Patterns Playgrounds – Playground that show various traditional design patterns.
- Design Patterns Playground – Learning GoF’s Design Patterns in Swift 2.
Protocol Oriented Programming
- Swift Diagram Playgrounds – Adaptation of the Protocol-Oriented Programming in Swift talk from WWDC 2015.
- Swift Protocol Extensions – A playground to explore Protocol Extensions.
- Battleship Example – An example of how to use Protocol Oriented Programming with the battleship game.
Functional Reactive Programming
- ReactiveCocoa Playground – The easiest way to get a taste of ReactiveCocoa.
- Swift Reactive Playground – Companion to the article: ReactiveCocoa made Simple With Swift.
Playgrounds from Apple, usually presented at some WWDC
- Apple’s Mandelbrot Playground – A playground with the mandelbrot fractal (updated to Swift2 by @palmerc).
- Apple’s Balloons Playground – The balloons playground showed at WWDC14.
- Interactive Playgrounds – Playground that presents the interactive playgrounds feature with a UIKit dynamics Newton’s cradle.
- Apple’s Crustacean Playground – Protocol-Oriented Programming with Value Types
- Apple’s Swift Standard Library Playground – experiment with Swift standard library types and high-level concepts using visualizations and practical examples.
Playgrounds about Playgrounds
Playgrounds that describe what you can do with playgrounds
- Interactive Playground – Exploring interactivity in Playgrounds in Xcode 7.3.
- XCTest Playground – Better looking tests for playgrounds
- Mondrian – Make iOS app mockups in Swift 2.x playgrounds.
Algorithms and Data Structures
Algorithms and data structures implemented in Swift
- Learn about transducers – A little tutorial that explains transducers.
- Swift Functors, Applicatives, and Monads in Pictures – Companion to the article: Swift Functors, Applicatves, and Monads in Pictures.
- Functors in Swift – A playground to introduce Functors in Swift, and their practical usage.
- DataStructures Playground – Data Structures and Algorithms in Swift.
- Swiftography – Standard cryptographic algorithms in a Swift Playground.
- Algorithms Playground – Various algorithm implementation in Swift.
- Dynamic Programming With Swift – A set of three dynamic programming problems implemented in a Swift.
- Swift Algorithm Club – Algorithms and data structures in Swift with explanations.
- Sorting Experiments – Alluring experiments with sorting algorithms in Swift, sort of.
- The Jelly Bean Problem – The Jelly Bean problem from Wait But Why.
- Euclidean Strings – A playground leveraging ReSwift to generate Euclidean Strings.
UIKit And Graphics
A list of playgrounds that demostrate various aspect of UIKit and other graphical frameworks
- UIStackView Playground – Interesting examples of use of UIStackViews.
- Bezier Path Playgrounds – Some playgrounds to better understand UIBezierPaths.
- RPClarity – Shows a technique for blurring an image behind the characters behind one or more UILabels.
- Swift Clock – An animated clock in a swift playground.
- Checkmark Button – Animated check mark button.
- UIKit playground – Playgrounds to experiment interactively with UIKit views.
- WatchKit Asset Playground – A swift playground for creating awesome animations for your WatchKit Apps.
- Swift 2.0 Protocol Extension Example – Showing how to use Swift2 protocol extensions to render errors in UIViews and UIViewControllers without subclassing or creating classes.
- Tinting – A small playground to demonstrate image tinting in UIKit.
- Animated GIF Playground – Swift playground for generating animated GIFs.
- Ray tracing Playground – A playground and a series of articles on ray tracing, see also part 2, 3, 4, 5
- WWDC16 Logo Playground – Drawing the WWDC16 logo in a playground.
- WWDC16 Typography – Draw a logo or any text with the WWDC16 ASCII texture.
- Interpolation Playground – Playground demonstrating lerp, smooth step, Catcall-Rom and others!
- CoreImage for Swift Playgrounds – Growing collection of CoreImage playgrounds from the upcoming book “CoreImage For Swift”.
- Image Processor – Implementing different image filter algorithms.
- METAL Playground – Apple Metal framework playground.
- Metalbrot – Interactive playground that draws the Mandelbrot fractal with Metal.
- iOS Animation Samples – Experiment with iOS animations.
- Additive Animations – Experiment with multiple additive animations in Core Animation.
- Core Animation Playground – Companion to Apple’s Core Animation Programming Guide.
- Duet-Inspired Trail Effect – How to get a Duet style trailing effect in SpriteKit.
- Sprite Kit Collisions – Demonstrates how to perform physics collision detection using Swift and Sprite Kit.
- SceneKit Examples – Experiment with SceneKit and Swift.
Sounds and music
- Bach Playground – A Simple Swift Playground that plays a brief piece by Bach with AVAudioEngine and AVMIDIPlayer.
- PlayerNode Playground – Playground using AVAudioEngine with a playernode and effects to play an audio file.
Live math with playgrounds
- Lindenmayer Systems – A Swift playground exploring Lindemayer systems.
- Swift Accelerate – Using the Accelerate framework and Swift for Linear Algebra.
- Swifty Mathematics – A collection of swift playground about mathematics.
- Numerical Algorithms – Numerical argorithms playground from Ray Wenderlich.
- Swift Natural Numbers – A playground for implementing the natural numbers and more concepts in number theory.
Library tutorials, in a playground
- Argo Playground – JSON decoding with Argo.
- Parse Playground – Experimenting with Parse.com in Swift.
- S3Uploader – A playground to upload images to AWS S3.
- 100 AudioKit Playgrounds – Audio synthesis and processing with AudioKit.
- AIToolbox – A set of playgrounds showing machine learning algorithms, all implemented with pieces of the AIToolbox framework code.
- Realm Swift Playground – A playground that demos the basic features of Realm in swift.
Sets of playgrounds about various topics
- Public Extensions – A set of useful extensions from @PublicExtension.
- Sketchytech’s Playgrounds – Various Playgrounds.
- Parks And Recreation – Great collection of interesting playgrounds, for fun and for profit.
- Swift fun playgrounds – A few playgrounds to showcase Swift peculiar features.
- BradLarson’s Playgrounds – Various playgrounds.
- Dmikusa’s Playgrounds – Playgrounds that show basic Swift, JSON parsing, sending HTTP requests and basic file IO.
- Cananito’s Playgrounds – Various playgrounds.
- Mgrebenets’s Playgrounds – Various playgrounds.
- Uberbruns’s Playgrounds – Various playgrounds.
- URaimo’s Playgrounds – My playgrounds, various topics.
- ManuelCarlos’s Playgrouds – Various playgrounds.
What doesn’t fit anywhere else, but still awesome
- Turtle Playground – A playground with Logo-like commands.
- Game Boards – Chess, checkers, tic-tac-toe, sudoku and many others in playground.
- Swift Brainfuck – Brainfuck interpreter written in Swift using Playground.
- Icon Creator – Create app icons on Swift playground.
- StarWars Seals – Emblems from Star Wars in Swift playgrounds via CoreGraphics and UIViews
- SwiftFiles – Save, Load and Delete files easily from within a Swift playground.
- Register VM – A register-based VM in a Swift playground.
- Earth photos – A slideshow of Earth photos taken by DSCOVR/EPIC.
- 2048 Playground – The 2048 game implemented with a playground.