Getting the Most out of Playgrounds in Xcode

Similar documents
What s New in imessage Apps

Extending Your Apps with SiriKit

Introducing Swift Playgrounds

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016

What s New in Cocoa for macos

What s New in tvos 12

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

Leveraging Touch Input on ios

What s New in Xcode App Signing

Vision Framework. Building on Core ML. Media #WWDC17. Brett Keating, Apple Manager Frank Doepke, He who wires things together

What s New in MapKit. App Frameworks #WWDC17. Fredrik Olsson

Enhancing your apps for the next dimension of touch

Touch Bar Fundamentals

LESSONS LEARNED. SWIFT. Dagna Bieda, 7th April 2016

What's New in UIKit Dynamics and Visual Effects Session 229

Core ML in Depth. System Frameworks #WWDC17. Krishna Sridhar, Core ML Zach Nation, Core ML

Media and Gaming Accessibility

Introducing the Modern WebKit API

WatchKit In-Depth, Part 2

Adopting Advanced Features of the New UI

Using and Extending the Xcode Source Editor

What s New in tvos #WWDC16. App Frameworks. Session 206. Hans Kim tvos Engineer

Data Delivery with Drag and Drop

Getting Started with CareKit

What s New in Core Image

Integrating Apps and Content with AR Quick Look

Advanced Notifications

Introducing the Photos Frameworks

Swift API Design Guidelines

Building Faster in Xcode

Cocoa Touch Best Practices

lecture 10 UI/UX and Programmatic Design cs : spring 2018

ios Memory Deep Dive #WWDC18 Kyle Howarth, Software Engineer James Snee, Software Engineer Kris Markel, Software Engineer

Implementing UI Designs in Interface Builder

ios Accessibility Developing for everyone Session 201 Ian Fisch ios Accessibility

Accessibility on OS X

Quick Interaction Techniques for watchos

What's New in Core Spotlight

Mastering UIKit on tvos

Mastering Drag and Drop

Thread Sanitizer and Static Analysis

Custom Views and Events. Lecture 7

Building Better Apps with Value Types in Swift Session 414

Building Visually Rich User Experiences

What s New in Testing

Authoring Playground Books with Bluefruit for ios

Localizing with Xcode 6

Building Apps with Dynamic Type

View Controller Advancements for ios8

Storyboards and Controllers on OS X

Advanced Scrollviews and Touch Handling Techniques

What s New in CloudKit

imessage Apps and Stickers, Part 2

Accessibility on ios. Developing for everyone. Frameworks #WWDC14. Session 210 Clare Kasemset ios Accessibility

New UIKit Support for International User Interfaces

Introducing PDFKit on ios

Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee

Understanding Undefined Behavior

Finding Bugs Using Xcode Runtime Tools

Creating Complications with ClockKit Session 209

CSC 581: Mobile App Development Spring 2019

View Controller Lifecycle

Optimizing Swift Performance Session 409

Lecture 5 Demo Code: FaceIt MVC and Gestures

Introducing On Demand Resources

Localizing with Xcode 9

Building for Voice with Siri Shortcuts

Seamless Linking to Your App

Contents. iphone Training. Industry Trainers. Classroom Training Online Training ON-DEMAND Training. Read what you need

Improving your Existing Apps with Swift

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Modern User Interaction on ios

What s New in LLDB. Debug your way to fame and glory #WWDC15. Developer Tools. Session 402

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016

Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee

SceneKit: What s New Session 604

Using Accelerate and simd

Introduction to Siri Shortcuts

Getting Published in Apple News

What s New in Core Data?

Mysteries of Auto Layout, Part 1

What s New in Cocoa. App Frameworks #WWDC17. Ali Ozer Daphne Larose

Introducing Password AutoFill for Apps

What s New in Cocoa #WWDC14. Frameworks. Session 204 Ali Ozer Director of Cocoa Frameworks

SceneKit in Swift Playgrounds

Adapting to the New UI of OS X Yosemite

What s New in NSCollectionView Session 225

What s New in SpriteKit

Objective-C Primer. iphone Programmer s Association. Lorenzo Swank September 10, 2008

ITP 342 Mobile App Dev. Animation

What s New in ARKit 2

Introducing the Contacts Framework

Getting to Know Swift Package Manager

Advanced Debugging and the Address Sanitizer

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

What s New in Swift Playgrounds

Enabling Your App for CarPlay

Announcements. Today s Topics

Transcription:

#WWDC18 Getting the Most out of Playgrounds in Xcode Session 402 Tibet Rooney-Rabdau, Xcode Engineer Alex Brown, Core OS Engineer TJ Usiyan, Xcode Engineer 2018 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

Fundamentals Running step by step Advanced techniques

Fundamentals Running step by step Advanced techniques

A Quick Tour

Live View

Live View UIView and UIViewController

Live View UIView and UIViewController NSView and NSViewController

// Live View import PlaygroundSupport let viewcontroller = /*... */ PlaygroundPage.current.liveView = viewcontroller

// Live View import PlaygroundSupport let viewcontroller = /*... */ PlaygroundPage.current.liveView = viewcontroller

// Live View import PlaygroundSupport let viewcontroller = /*... */ PlaygroundPage.current.liveView = viewcontroller

// Live View import PlaygroundSupport let viewcontroller = /*... */ PlaygroundPage.current.liveView = viewcontroller

Markup Use markup to show formatted text

// Markup //: Roses are red //: //: Violets are blue //: //: Writing your markup //: //: Is so fun to do!

// Markup /*: Roses are red Violets are blue Writing your markup */ Is so fun to do!

// Markup // Headings //: # Roses Are Red //: ## An ode to markup //: ### By: Tibet Rooney-Rabdau

Roses Are Red An ode to markup By: Tibet Rooney-Rabdau Roses are red Violets are blue Writing your markup Is so fun to do!

// Markup // Formatting Characters //: Roses are *red* //: //: Violets are *blue* //: //: Writing your `markup` //: //: Is so **fun** to do!

// Markup // Formatting Characters //: Roses are *red* //: //: Violets are *blue* //: //: Writing your `markup` //: //: Is so **fun** to do!

// Markup // Formatting Characters //: Roses are *red* //: //: Violets are *blue* //: //: Writing your `markup` //: //: Is so **fun** to do!

// Markup // Formatting Characters //: Roses are *red* //: //: Violets are *blue* //: //: Writing your `markup` //: //: Is so **fun** to do!

Roses are red Violets are blue Writing your markup Is so fun to do!

// Markup // Numbered Lists //: 1. Roses are red //: 2. Violets are blue //: 3. Writing your markup //: 4. Is so fun to do!

1. Roses are red 2. Violets are blue 3. Writing your markup 4. Is so fun to do!

// Markup // Bulleted Lists //: * Roses are red //: * Violets are blue //: * Writing your markup //: * Is so fun to do!

Roses are red Violets are blue Writing your markup Is so fun to do!

// Markup // Links //: [Roses](https://en.wikipedia.org/wiki/Rose) are red //: //: [Violets](https://en.wikipedia.org/wiki/Viola_(plant)) are blue

// Markup // Links //: [Roses](https://en.wikipedia.org/wiki/Rose) are red //: //: [Violets](https://en.wikipedia.org/wiki/Viola_(plant)) are blue //: //: Writing your markup //: //: Is so [fun][1] to do! //: //: [1]: https://en.wikipedia.org/wiki/fun

Roses are red Violets are blue Writing your markup Is so fun to do!

// Markup // Navigating Between Pages //: [Previous](@previous) //: //: [Next](@next) //: //: [Formatting Characters](Formatting%20Characters)

// Markup // Navigating Between Pages //: [Previous](@previous) //: //: [Next](@next) //: //: [Formatting Characters](Formatting%20Characters)

// Markup // Navigating Between Pages //: [Previous](@previous) //: //: [Next](@next) //: //: [Formatting Characters](Formatting%20Characters)

// Markup // Navigating Between Pages //: [Previous](@previous) //: //: [Next](@next) //: //: [Formatting Characters](Formatting%20Characters)

Sources Swift source files Multiple levels Playground wide Per page Compiled as separate modules Automatically imported Use access control

Resources Any file type Multiple levels Playground wide Per page

// Using Resources in Playgrounds //: You can embed an image in markup: //:![alternate text](mypicture.jpg "hover title") // You can also access the same image in code: let image = UIImage(named: "MyPicture") //: You can use videos in markup: //:![alternate text](myvideo.mp4 poster="myposter.jpg" width="integer width" height="integer height") // You can find resources by using Bundle APIs: let videourl = Bundle.main.url(forResource: "MyVideo", withextension: "mp4")

// Using Resources in Playgrounds //: You can embed an image in markup: //:![alternate text](mypicture.jpg "hover title") // You can also access the same image in code: let image = UIImage(named: "MyPicture") //: You can use videos in markup: //:![alternate text](myvideo.mp4 poster="myposter.jpg" width="integer width" height="integer height") // You can find resources by using Bundle APIs: let videourl = Bundle.main.url(forResource: "MyVideo", withextension: "mp4")

// Using Resources in Playgrounds //: You can embed an image in markup: //:![alternate text](mypicture.jpg "hover title") // You can also access the same image in code: let image = UIImage(named: "MyPicture") //: You can use videos in markup: //:![alternate text](myvideo.mp4 poster="myposter.jpg" width="integer width" height="integer height") // You can find resources by using Bundle APIs: let videourl = Bundle.main.url(forResource: "MyVideo", withextension: "mp4")

// Using Resources in Playgrounds //: You can embed an image in markup: //:![alternate text](mypicture.jpg "hover title") // You can also access the same image in code: let image = UIImage(named: "MyPicture") //: You can use videos in markup: //:![alternate text](myvideo.mp4 poster="myposter.jpg" width="integer width" height="integer height") // You can find resources by using Bundle APIs: let videourl = Bundle.main.url(forResource: "MyVideo", withextension: "mp4")

// Using Resources in Playgrounds //: You can embed an image in markup: //:![alternate text](mypicture.jpg "hover title") // You can also access the same image in code: let image = UIImage(named: "MyPicture") //: You can use videos in markup: //:![alternate text](myvideo.mp4 poster="myposter.jpg" width="integer width" height="integer height") // You can find resources by using Bundle APIs: let videourl = Bundle.main.url(forResource: "MyVideo", withextension: "mp4")

More Information Markup Formatting Reference Playground Support developer.apple.com

NEW Running Step by Step Alex Brown, Core OS Engineer

Why Run Step by Step? Execute one more line fast Respond to live data Re-running can give you different values

Demo

Running Step by Step Explore your idea a line at a time Have a conversation between code and data Use Shift-Return to run up to current line Interact with dynamic live views

Step by Step Suggestions Create a follow-along tutorial for your API

Step by Step Suggestions Create a follow-along tutorial for your API Explore data from maps, public statistics, or a class project

Step by Step Suggestions Create a follow-along tutorial for your API Explore data from maps, public statistics, or a class project Create and play a game or animation on the fly

Playgrounds Are Serious Fun Explore code and data interactively Learn and use Apple APIs Import your Frameworks Display focused results Introducing Create ML WWDC 2018

Advanced Techniques TJ Usiyan, Xcode Engineer

Advanced Techniques Custom Playground Display Convertible Using custom frameworks in playgrounds Troubleshooting

Advanced Techniques Custom Playground Display Convertible Using custom frameworks in playgrounds Troubleshooting

Custom Playground Display Convertible NEW New CustomPlaygroundDisplayConvertible protocol Introduced in Xcode 9.3 and Swift 4.1 Replaces CustomPlaygroundQuickLookable (Deprecated in Xcode 9.3)

Custom Playground Display Convertible extension MyType: CustomPlaygroundDisplayConvertible { } var playgrounddescription: Any {... }

Custom Playground Display Convertible Supported types in Xcode 9.3/Swift 4.1 and later Textual Graphical String, NSString Int, UInt (including the sized variants) Float, Double Bool Date, NSDate NSAttributedString NSNumber NSRange URL, NSURL CGPoint CGSize CGRect NSColor, UIColor, CGColor, CIColor NSImage, UIImage, CGImage, CIImage NSBezierPath, UIBezierPath NSView, UIView

Advanced Techniques Custom Playground Display Convertible Using custom frameworks in playgrounds Troubleshooting

Importing Your Code in Playgrounds

Importing Your Code in Playgrounds

Remember to build before you run

Importing Your Code in Playgrounds

Importing Your Code in Playgrounds

Demo

Fundamentals Running step by step Advanced techniques

A Playground in Every Project!

More Information https://developer.apple.com/wwdc18/402 Creating Content for Swift Playgrounds Lab Technology Lab 10 Friday 12:00PM