Slide 1

Slide 1 text

1 The Xcode Survival Guide Kristina Fox 
 Senior iOS Engineer
 @krstnfx

Slide 2

Slide 2 text

kristina.io | @krstnfx | #devweek2019 2 Hi, I’m Kristina ⛸

Slide 3

Slide 3 text

3

Slide 4

Slide 4 text

The Xcode Survival Guide

Slide 5

Slide 5 text

kristina.io | @krstnfx | #devweek2019 5

Slide 6

Slide 6 text

kristina.io | @krstnfx | #devweek2019 6

Slide 7

Slide 7 text

kristina.io | @krstnfx | #devweek2019 7

Slide 8

Slide 8 text

kristina.io | @krstnfx | #devweek2019 8 ✨

Slide 9

Slide 9 text

kristina.io | @krstnfx | #devweek2019 9

Slide 10

Slide 10 text

kristina.io | @krstnfx | #devweek2019 10

Slide 11

Slide 11 text

kristina.io | @krstnfx | #devweek2019 11 Pete’s very strange day )

Slide 12

Slide 12 text

kristina.io | @krstnfx | #devweek2019 12

Slide 13

Slide 13 text

kristina.io | @krstnfx | #devweek2019 13

Slide 14

Slide 14 text

kristina.io | @krstnfx | #devweek2019 14

Slide 15

Slide 15 text

kristina.io | @krstnfx | #devweek2019 15

Slide 16

Slide 16 text

kristina.io | @krstnfx | #devweek2019 16 Color assets

Slide 17

Slide 17 text

kristina.io | @krstnfx | #devweek2019 17

Slide 18

Slide 18 text

kristina.io | @krstnfx | #devweek2019 18 Lock Storyboard Elements Lock -> All Properties

Slide 19

Slide 19 text

kristina.io | @krstnfx | #devweek2019 19 20:00

Slide 20

Slide 20 text

kristina.io | @krstnfx | #devweek2019 20

Slide 21

Slide 21 text

kristina.io | @krstnfx | #devweek2019 21 Multiple assistant editors

Slide 22

Slide 22 text

kristina.io | @krstnfx | #devweek2019 22

Slide 23

Slide 23 text

kristina.io | @krstnfx | #devweek2019 23 Assistant editor view mode All Editors Stacked Horizontally

Slide 24

Slide 24 text

kristina.io | @krstnfx | #devweek2019 24 Select file view location Alt + Shift + Click

Slide 25

Slide 25 text

kristina.io | @krstnfx | #devweek2019 25

Slide 26

Slide 26 text

kristina.io | @krstnfx | #devweek2019 26

Slide 27

Slide 27 text

kristina.io | @krstnfx | #devweek2019 27 Change command-click option

Slide 28

Slide 28 text

kristina.io | @krstnfx | #devweek2019 28 Quick Open function List Ctrl + 6

Slide 29

Slide 29 text

kristina.io | @krstnfx | #devweek2019 29 Search function signatures Ctrl + 6 Just start typing

Slide 30

Slide 30 text

kristina.io | @krstnfx | #devweek2019 30 // // DryExecutionHandler.swift // Resin // import Foundation class DryExecutionHandler: NSObject { override init() { let network = Network() network.executeDrying() } } // // RinseExecutionHandler.swift // Resin // import Foundation class RinseExecutionHandler: NSObject { override init() { let network = Network() network.executeRinsing() } } // // StickExecutionHandler.swift // Resin // // import Foundation class StickExecutionHandler: NSObject { override init() { let network = Network() network.executeStickiness() } }

Slide 31

Slide 31 text

kristina.io | @krstnfx | #devweek2019 31 // // Network.swift // Resin // import Foundation class Network: NSObject { func executeDrying() { let url = "resin-prod.com/dry" executeAction(url: url) } func executeStickiness() { let url = "resin-prod.com/sticky" executeAction(url: url) } func executeRinsing() { let url = "resin-dev.com/rinse" executeAction(url: url) } }

Slide 32

Slide 32 text

kristina.io | @krstnfx | #devweek2019 32 // // Network.swift // Resin // import Foundation class Network: NSObject { func executeDrying() { let url = "resin-prod.com/dry" executeAction(url: url) } func executeStickiness() { let url = "resin-prod.com/sticky" executeAction(url: url) } func executeRinsing() { let url = "resin-dev.com/rinse" executeAction(url: url) } }

Slide 33

Slide 33 text

kristina.io | @krstnfx | #devweek2019 33 // // Network.swift // Resin // import Foundation class Network: NSObject { func executeDrying() { let url = "resin-prod.com/dry" executeAction(url: url) } func executeStickiness() { let url = "resin-prod.com/sticky" executeAction(url: url) } func executeRinsing() { let url = "resin-dev.com/rinse" executeAction(url: url) } }

Slide 34

Slide 34 text

kristina.io | @krstnfx | #devweek2019 34 User Defined Build Settings Project file -> Build Settings -> User-Defined Settings 02:49

Slide 35

Slide 35 text

kristina.io | @krstnfx | #devweek2019 35

Slide 36

Slide 36 text

kristina.io | @krstnfx | #devweek2019 36 ✅ Stage 1 complete

Slide 37

Slide 37 text

kristina.io | @krstnfx | #devweek2019 37

Slide 38

Slide 38 text

kristina.io | @krstnfx | #devweek2019 38

Slide 39

Slide 39 text

kristina.io | @krstnfx | #devweek2019 39

Slide 40

Slide 40 text

kristina.io | @krstnfx | #devweek2019 40

Slide 41

Slide 41 text

kristina.io | @krstnfx | #devweek2019 41

Slide 42

Slide 42 text

kristina.io | @krstnfx | #devweek2019 42 Device Crash Logs 1. Windows -> Devices and Simulators 2. Choose Devices tab 3. View device logs

Slide 43

Slide 43 text

kristina.io | @krstnfx | #devweek2019 43 “Catch all” Breakpoints

Slide 44

Slide 44 text

kristina.io | @krstnfx | #devweek2019 44 Editing Breakpoints

Slide 45

Slide 45 text

kristina.io | @krstnfx | #devweek2019 45 Add an Action

Slide 46

Slide 46 text

kristina.io | @krstnfx | #devweek2019 46 // // Room.swift // GasMask // import Foundation class Room: NSObject, NSCoding { var name: String? var id: Int? required init?(coder aDecoder: NSCoder) { self.name = aDecoder.decodeObject(forKey: "names") as? String self.id = aDecoder.decodeObject(forKey: "id") as? Int } func encode(with aCoder: NSCoder) { aCoder.encode(self.name, forKey: "name") aCoder.encode(self.id, forKey: "id") } }

Slide 47

Slide 47 text

kristina.io | @krstnfx | #devweek2019 47 // // Room.swift // GasMask // import Foundation class Room: NSObject, NSCoding { var name: String? var id: Int? required init?(coder aDecoder: NSCoder) { self.name = aDecoder.decodeObject(forKey: "names") as? String self.id = aDecoder.decodeObject(forKey: "id") as? Int } func encode(with aCoder: NSCoder) { aCoder.encode(self.name, forKey: "name") aCoder.encode(self.id, forKey: "id") } }

Slide 48

Slide 48 text

kristina.io | @krstnfx | #devweek2019 48 // // Room.swift // GasMask // import Foundation class Room: NSObject, NSCoding { var name: String? var id: Int? required init?(coder aDecoder: NSCoder) { self.name = aDecoder.decodeObject(forKey: "names") as? String self.id = aDecoder.decodeObject(forKey: "id") as? Int } func encode(with aCoder: NSCoder) { aCoder.encode(self.name, forKey: "name") aCoder.encode(self.id, forKey: "id") } }

Slide 49

Slide 49 text

kristina.io | @krstnfx | #devweek2019 49 struct Rooms: Codable { var name: String var id: Int }

Slide 50

Slide 50 text

kristina.io | @krstnfx | #devweek2019 50 Custom Code Snippets 1. Highlight code 2. Drag to code snippets window 3. Drop & fill completion shortcut

Slide 51

Slide 51 text

kristina.io | @krstnfx | #devweek2019 51 Custom Code Snippets in Use 4. Profit

Slide 52

Slide 52 text

kristina.io | @krstnfx | #devweek2019 52

Slide 53

Slide 53 text

kristina.io | @krstnfx | #devweek2019 53

Slide 54

Slide 54 text

kristina.io | @krstnfx | #devweek2019 54

Slide 55

Slide 55 text

kristina.io | @krstnfx | #devweek2019 55 ✅ Stage 2 complete

Slide 56

Slide 56 text

kristina.io | @krstnfx | #devweek2019 56

Slide 57

Slide 57 text

kristina.io | @krstnfx | #devweek2019 57

Slide 58

Slide 58 text

kristina.io | @krstnfx | #devweek2019 58 SUDDEN DEATH ☠

Slide 59

Slide 59 text

kristina.io | @krstnfx | #devweek2019 59 > Your colleague is having a hard time debugging an animation in simulator. What do you suggest?

Slide 60

Slide 60 text

kristina.io | @krstnfx | #devweek2019 60 Debug animations

Slide 61

Slide 61 text

kristina.io | @krstnfx | #devweek2019 61 > You want to use one of your own photos to test your app. What’s the best way to load it in simulator?

Slide 62

Slide 62 text

kristina.io | @krstnfx | #devweek2019 62 Drag and Drop Media into simulator

Slide 63

Slide 63 text

kristina.io | @krstnfx | #devweek2019 63 > What’s the easiest way to find all strings that look like email addresses in your app?

Slide 64

Slide 64 text

kristina.io | @krstnfx | #devweek2019 64 Pattern Matching in Search

Slide 65

Slide 65 text

kristina.io | @krstnfx | #devweek2019 65 Pattern Matching in Search

Slide 66

Slide 66 text

kristina.io | @krstnfx | #devweek2019 66 > Looks like your colleague used a regular expression before to search, but can’t remember what it was. What do you recommend?

Slide 67

Slide 67 text

kristina.io | @krstnfx | #devweek2019 67 Search history

Slide 68

Slide 68 text

kristina.io | @krstnfx | #devweek2019 68 > Say you have to replace some old prefixed enum code: enum APPLFontStyle { case APPLFontStyleBold case APPLFontStyleItalic case APPLFontStyleUnderline case APPLFontStyleStrikethrough } > Know any shortcuts?

Slide 69

Slide 69 text

kristina.io | @krstnfx | #devweek2019 69 Multiple Cursors Option + drag (rectangular selection) Ctrl + shift + click (place multiple cursors)

Slide 70

Slide 70 text

kristina.io | @krstnfx | #devweek2019 70 > How do you debug an issue where the root cause is poor network connectivity?

Slide 71

Slide 71 text

kristina.io | @krstnfx | #devweek2019 71 Network link simulator

Slide 72

Slide 72 text

kristina.io | @krstnfx | #devweek2019 72 Network link simulator

Slide 73

Slide 73 text

kristina.io | @krstnfx | #devweek2019 73 Network link simulator

Slide 74

Slide 74 text

kristina.io | @krstnfx | #devweek2019 74 Network link simulator

Slide 75

Slide 75 text

kristina.io | @krstnfx | #devweek2019 75 Network link simulator

Slide 76

Slide 76 text

kristina.io | @krstnfx | #devweek2019 76 30 questions later…

Slide 77

Slide 77 text

kristina.io | @krstnfx | #devweek2019 77 > What is your spirit animal?

Slide 78

Slide 78 text

kristina.io | @krstnfx | #devweek2019 78

Slide 79

Slide 79 text

kristina.io | @krstnfx | #devweek2019 79 ✅ Stage 3 complete

Slide 80

Slide 80 text

kristina.io | @krstnfx | #devweek2019 80

Slide 81

Slide 81 text

kristina.io | @krstnfx | #devweek2019 81 456

Slide 82

Slide 82 text

kristina.io | @krstnfx | #devweek2019 82 Based on a true story Just kidding

Slide 83

Slide 83 text

kristina.io | @krstnfx | #devweek2019 83 Xcode Survival Guide Cheat Sheet Name Location Shortcut Color assets Assets folder Add color set Lock storyboard Identity Inspector Lock - all properties Side-by-side editors View -> Assistant Editor All editors stacked horizontally Place file in editor Keyboard/Mouse Alt + Shift (Click on file) Select Code Structure Keyboard/Mouse Command + click (on function)

Slide 84

Slide 84 text

kristina.io | @krstnfx | #devweek2019 84 Xcode Survival Guide Cheat Sheet Name Location Shortcut Pre-Xcode 8 style Jump Xcode Settings -> Navigation Command-click on Code ->Jumps to Definition User Defined Environment Variables Project File -> Build Settings Add variables to User-Defined Settings Device Logs for CrashesWindow -> Devices and Simulators View device logs Catch All Breakpoints Breakpoints panel Plus button on bottom left Edit Breakpoints Breakpoints Panel Double-click blue breakpoint to bring up action menu

Slide 85

Slide 85 text

kristina.io | @krstnfx | #devweek2019 85 Xcode Survival Guide Cheat Sheet Name Location Shortcut Slow animations Simulator -> Debug Slow animations Custom photos Simulator Drag and drop photo Pattern matching in search/Search History Search sidebar Click on magnifying glass drop down, Insert Pattern/Recent Queries Multiple cursors Editor Ctrl + shift +click (place cursors)
 Option + drag (rectangular selection) Simulate poor network System Preferences Network Link Conditioner

Slide 86

Slide 86 text

kristina.io | @krstnfx | #devweek2019 86 Paul Hudson’s Swift Knowledge Base
 https://www.hackingwithswift.com/example-code/ API Endpoint Configuration
 https://medium.com/@danielgalasko/change-your-api-endpoint-environment- using-xcode-configurations-in-swift-c1ad2722200e Type Safe JSON in Swift
 https://medium.com/grand-parade/creating-type-safe-json-in-swift-74a612991893 WWDC-Style Code Snippets
 https://kristina.io/tutorial-wwdc-style-live-code-snippets/ Resources

Slide 87

Slide 87 text

kristina.io | @krstnfx | #devweek2019 87 How To Simulate A Bad Network Connection On Your iOS Device and Simulator
 https://www.natashatherobot.com/simulate-bad-network-ios-simulator/ Regular Expression Search
 https://medium.com/@onmyway133/regular-expression-search-in- xcode-28a1a17fc863 Twitter iOS Community (@twostraws, @aligatr, @_inside & many more!)
 https://twitter.com/krstnfx/status/940265683690180608 Resources

Slide 88

Slide 88 text

kristina.io | @krstnfx | #devweek2019 88 Thank you! Questions? 8