Slide 1

Slide 1 text

by Daniel Mikusa Software Support Engineer @ Pivotal Basic App Development with Swift

Slide 2

Slide 2 text

About Me ● Daniel Mikusa ○ Blog / Website ○ Twitter / Google Plus ○ Github (Work) / Github (Personal) ● Long time Mac user ● Professional software developer ● Interested in building tools for my desktop ● Still learning Swift & Mac Dev

Slide 3

Slide 3 text

Agenda ● Introduction ● Swift ● Xcode ● Important Libraries ● Where to go next?

Slide 4

Slide 4 text

Introduction ● Goals ○ introduce dev tools ○ show relevant parts of Swift ○ show how to build some basic apps for your Mac ● Out of scope ○ iOS Development ○ Mastery of... ■ Swift language ■ Mac OSX APIs ■ XCode & other dev tools ○ XCode 7 & Swift 2

Slide 5

Slide 5 text

Prerequisites ● Install XCode ● Use Yosemite & XCode 6.3+ ● Optional but recommended ○ Carthage - github.com/Carthage/Carthage ○ CocoaPods - cocoapods.org

Slide 6

Slide 6 text

Swift Language ● Features ○ A compiled language ○ Has static, strongly typed objects ○ Intended to be more concise, safer and robust than Objective-C ○ Designed to work w/Cocoa & CocoaTouch ○ Works well w/existing C, Obj-C and C++ code ○ Automatic memory management via ARC ● Reference Links ○ Home Page ○ A Swift Tour ○ Reference Docs ○ Other useful links

Slide 7

Slide 7 text

Playgrounds ● REPL (Read-Eval-Print-Loop) Environment for running Swift Code ● Excellent for learning, quickly building and iterating on your code and exploring new APIs ● Works with GUI classes too ● Easy way to share code samples and a great tool for presentations

Slide 8

Slide 8 text

Testing ● It’s always good to test your code ● Uses XCTestCase ● Similar to unit tests in many other languages ● One caveats… ○ Tests are in a separate target, which only gives you access to public methods & properties (fixed in 2.0)

Slide 9

Slide 9 text

Gotchas & Problems ● Swift is still very new ○ Heard reports of compiler bugs ○ Have had problems compiling third party code ○ Language & compiler are still evolving ○ Not all docs have Swift examples ○ StackOverflow and other resources limited / dated ● Xcode 6.3.2 w/Yosemite seems stable, but previous versions crashed constantly w/Playgrounds & Swift ● www.textfromxcode.com

Slide 10

Slide 10 text

One of my favorites from textfromxcode.com...

Slide 11

Slide 11 text

Swift Demos

Slide 12

Slide 12 text

XCode - Real Estate

Slide 13

Slide 13 text

XCode - Real Estate Toggle Sections on / off

Slide 14

Slide 14 text

XCode - Real Estate Run / Test / Profile / Analyze Button Schema & Target selection Status Bar Assistant Editor Mode Standard Editor Mode VCS Mode

Slide 15

Slide 15 text

XCode Basics Demo

Slide 16

Slide 16 text

XCode - Building GUIs ● XIB file ○ XCode shows as GUI, but is an XML file ○ Represents “objects” ○ Can contain visible & invisible objects ● Edit the XIB file visually ○ Drag & drop controls / wysiwyg style ● Large list of components available

Slide 17

Slide 17 text

Component Demo

Slide 18

Slide 18 text

XCode - Actions & Outlets ● Action ○ Sends a message from a control to code ○ Attach functionality to a button or other control ● Outlet ○ Reference to an object in the XIB file ○ Object automatically created and injected ○ Wire dependent objects together

Slide 19

Slide 19 text

XCode - Actions & Outlets Assistant Editor Mode (aka split panes)

Slide 20

Slide 20 text

XCode - Actions & Outlets Connections Inspector w/Action Connections Inspector w/Outlets

Slide 21

Slide 21 text

Actions & Outlets Demo

Slide 22

Slide 22 text

XCode - Bindings ● Bindings ○ keeps model and view in sync, automatically! ○ increase functionality, decrease code required ○ optionally can transform the data as it’s sync’d ○ other flexible configuration options

Slide 23

Slide 23 text

XCode - Basic Binding Model key path is linked to an object on the App Delegate

Slide 24

Slide 24 text

Binding Demo

Slide 25

Slide 25 text

Libraries ● Swift is the language ● Interacts with Object-C and C libraries ● Cocoa ○ Foundation + Application + Core Data ○ Includes things like… ■ File system access ■ Network access ■ Data access ■ Build GUI’s ■ Audio & Video

Slide 26

Slide 26 text

Libraries ● Third party libraries ○ Lots of open source libraries available ○ Cocoapods and Carthage are great ways to use them ● HTTP - Easier HTTP clients ○ Alamofire ○ Just ● SwiftyJSON - Nice JSON processor ● BrightFutures - Futures & Promises API

Slide 27

Slide 27 text

Libraries Demo

Slide 28

Slide 28 text

Where to go next? ● Apple Resources ○ Docs ○ Sample Code ○ Videos ● cocoapods.org ○ Great place to find third party libraries ● StackOverflow ● Swift Developer Blog

Slide 29

Slide 29 text

Questions

Slide 30

Slide 30 text

Feedback http://j.mp/psumac2015-119