I tried to create a UILabel
in playground but failed. Does playground only support OS X development for now?
In Xcode 8 XCPlaygroundPage.currentPage.liveView
is deprecated. Instead, use
import PlaygroundSupport
PlaygroundPage.current.liveView = view
YES, it does!
File: New > File... > iOS > Source > Playground
import UIKit
let lbl = UILabel(frame: CGRectMake(0, 0, 300, 100))
lbl.text = "Hello StackOverflow!"
Then, save the file. This will trigger the Playground to interpret UI related things. Sometimes you may need to toss in a trailing newline and save again -- its a beta. At this point, the word "UILabel" should appear on the right-hand side.
Now, to actually view what you've done, you've got to click on the "Quick View" eye on the right, or the white circle to open it in Assistant Editor:
Here's a screenshot of some basic things with UIImage working, etc.
Yeah looks like it doesn't support UIkit yet.
Update: When i wrote this answer in 2014 it didn't support UIKit, now it does. Leaving this for historical reference
Edit: Actually above answer is incorrect.
You can create iOS project and add new .playground file inside that project. Then you can import Uikit or another iOS specific framework.
Press CMD+Option+1 and change the platform to iOS, this will allow you to import UIKit.
Press Option+Cmd+1 and choose iOS in the Platform setting. Then you can import UIKit and play~
I found I could add a new playground file in IOS project, and in that file I can import UIKit.