How Do Playgrounds Work?

I have experience working with Swift 3 to create iOS apps, however I am trying to create a playground (for the WWDC scholarship) and I have no idea how they work.


I downloaded the following sample code from online, and added it to my iOS playground:

import UIKit
import PlaygroundSupport

let view = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 200))
view.backgroundColor = UIColor.blue

PlaygroundPage.current.liveView = view


However when I press the run button, it says that it is running but nothing happens.


Am I supposed to have an iOS simulator open? Am I supposed to be running a certain app that will show the output?

Sorry if I missed it - did you use a macOS target or an iOS target?


Do you have a supported iPad to test on?


Are you making a Playground or a Playground Book?

If you are using Xcode - click on the Assistant editor. That should run your playground.
If you are using an iPad - click the run my code button.


Based on your code, you should see a blue rectangle with width of 300 and height of 200.

How Do Playgrounds Work?
 
 
Q