While stuck at the Dr’s office, with my daughter being attended to, I decided to try editing a Swift 2.2 playground in iOS Playgrounds, to see if I could upgrade it to Swift 3.0.
The tl;dr is that the tools, while not fully baked, are just as amazing as they were in the WWDC demos. With a few (notable) exceptions, editing source code, invoking fixits, etc. are beautifully realized to the point that I was able to perform non-trivial edits while sitting in a waiting room and using an iPad:
I was able to fully update this playground page to run and render.
The Good
Built-in fixits are glorious. As in normal Xcode, they update code by inserting missing labels or replacing code:
Multiple errors are paged (as you can see with the two dots at the top of the complaint), and there’s amazing cross referencing with related items, such as when a protocol is not properly implemented or partially implemented. You just tap away to the error point for the candidate issue.
Number and color edits are fantastic: I didn’t realize you could use the number tweaker to just “dial” your way up and down numbers by continuing to twirl into the number pad:
Pages I didn’t expect to work did work! Like this one: It’s really short. Give it a try.
The Not So Good
You can’t fixit many errors:
But you can select things and start to type and Playgrounds picks up the context for you:
The Ugly
Screenshots are for live views, not playground views. And for some reason, I’m having a lot of difficulty today doing screenshots the old way (hold down sleep/wake, then click home). All of these screenshots are from Xcode’s device window instead.
A lot of confusion comes from inappropriate or missing tool tips. Sometimes it leads you down the garden path:
What was actually needed looks more like this:
Trying to edit “advancedBy” to “advanced” by moving the cursor to the end of By and backspacing was simply a no-go. Playgrounds will remove the entire call at once.
You get a lot of problems with 2.2 items needing to be lowercased for 3, or using old CG constructors like CGRectMake not auto-fixing to CGRect(x:y:width:height). Playgrounds just don’t quite get the “fixit” needed for these simple switches.
Even when you’re typing things in, Playgrounds doesn’t always offer you the right choices. In this example, all this needed was to lowercase CGAffineTransform to cgAffineTransform. No fixit and no syntax match:
The really cool “drag parenthesis pairs into place” shown in the demos don’t seem to work in the app yet. Instead all I could drag was the letter “j”. (Update: Drag down and left or down and right and then use a second finger to tap or drag the updated key. It is hard but doable. If you’re not coordinated, use two hands. Thanks Seán Labastille)
You can’t look up module definitions in-place.
No access to Sources that I can find so I can fix errors:
The live views are distorted:
But other than that, wow, what a cool tool. I’m really enjoying it a lot.
One Comment
Hi, thank you for sharing your experience. Is it possible to do Storyboard and Autolayout programatically with a Live View in Swift Playgrounds for iOS?