Slide 1

Slide 1 text

Playground Books How to make them today

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

How to make a book right now

Slide 9

Slide 9 text

playgroundbook github.com/ashfurrow/playgroundbook $ playgroundbook render MyBook.yaml $ playgroundbook lint MyBook.playgroundbook Validating MyBook.playgroundbook/...

Slide 10

Slide 10 text

Playground books support a rich set of awesome features to make learning how to code really easy, and this tool uses almost none of them. — Ash Furrow

Slide 11

Slide 11 text

My Goal 1. Write the code in Xcode 2. Build it there too 3. Run it in a host app 4. Unit-test the playground and LiveView code

Slide 12

Slide 12 text

//#-hidden-code import PlaygroundSupport private func ask(_ attribute: ShapeAttribute) { let page = PlaygroundPage.current if let proxy = page.liveView as? PlaygroundRemoteLiveViewProxy { let dict = PlaygroundValue.dictionary([ "method": .string("ask"), "attribute": .integer(attribute.rawValue) ]) proxy.send(dict) } } //#-end-hidden-code

Slide 13

Slide 13 text

PlaygroundSupportMock github.com/loufranco/PlaygroundSupportMock 1. Implements PlaygroundValue and the messaging prototypes 2. Lets you build, but doesn't actually do anything yet

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

pgbookc github.com/loufranco/pgbookc 1. File renaming 2. Special comments

Slide 17

Slide 17 text

Playground code //#-hidden-code import PlaygroundSupport let cloud = Shapes[5] //#-end-hidden-code func hasAttribute(shape: Shape, attribute: ShapeAttribute) -> Bool { let attributes: Set = shape.attributes return attributes.contains(attribute) } hasAttribute(shape: cloud, attribute: .IsGray)

Slide 18

Slide 18 text

App code //#-hidden-code import PlaygroundSupport let cloud = Shapes[5] //#-end-hidden-code func hasAttribute(shape: Shape, attribute: ShapeAttribute) -> Bool { let attributes: Set = shape.attributes return attributes.contains(attribute) } func Contents0102() -> Bool { return // REMOVE LINE hasAttribute(shape: cloud, attribute: .IsGray) } // REMOVE LINE

Slide 19

Slide 19 text

You can Unit Test! func testContents0102() { XCTAssert(Contents0102()) }

Slide 20

Slide 20 text

ShapeSearch github.com/loufranco/ShapeSearch 1. Book to teach binary search 2. Builds in a host app 3. Uses PlaygroundSupportMock and pgbookc 4. Can run LiveViews and unit test Playgrounds

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Thanks Get links on http://loufranco.com