Save 37% off PRO during our Black Friday Sale! »

Xcode Survival Guide

9455cf8cef7162321b21a354d27f6dba?s=47 Kristina Fox
February 20, 2019

Xcode Survival Guide

Want to take your Xcode skills to the next level? Join me as we take a literal journey through various tips, hacks, and tricks that can make you a more efficient iOS developer. Aimed at iOS developers from beginner to advanced, in this session attendees will walk away with at least one new trick up their sleeve to impress and delight their fellow iOS engineers. Presented at Developer Week 2019.

https://kristina.io

9455cf8cef7162321b21a354d27f6dba?s=128

Kristina Fox

February 20, 2019
Tweet

Transcript

  1. 1 The Xcode Survival Guide Kristina Fox 
 Senior iOS

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

  3. 3

  4. The Xcode Survival Guide

  5. kristina.io | @krstnfx | #devweek2019 5

  6. kristina.io | @krstnfx | #devweek2019 6

  7. kristina.io | @krstnfx | #devweek2019 7

  8. kristina.io | @krstnfx | #devweek2019 8 ✨

  9. kristina.io | @krstnfx | #devweek2019 9

  10. kristina.io | @krstnfx | #devweek2019 10

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

    )
  12. kristina.io | @krstnfx | #devweek2019 12

  13. kristina.io | @krstnfx | #devweek2019 13

  14. kristina.io | @krstnfx | #devweek2019 14

  15. kristina.io | @krstnfx | #devweek2019 15

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

  17. kristina.io | @krstnfx | #devweek2019 17

  18. kristina.io | @krstnfx | #devweek2019 18 Lock Storyboard Elements Lock

    -> All Properties
  19. kristina.io | @krstnfx | #devweek2019 19 20:00

  20. kristina.io | @krstnfx | #devweek2019 20

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

  22. kristina.io | @krstnfx | #devweek2019 22

  23. kristina.io | @krstnfx | #devweek2019 23 Assistant editor view mode

    All Editors Stacked Horizontally
  24. kristina.io | @krstnfx | #devweek2019 24 Select file view location

    Alt + Shift + Click
  25. kristina.io | @krstnfx | #devweek2019 25

  26. kristina.io | @krstnfx | #devweek2019 26

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

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

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

    + 6 Just start typing
  30. 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() } }
  31. 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) } }
  32. 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) } }
  33. 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) } }
  34. kristina.io | @krstnfx | #devweek2019 34 User Defined Build Settings

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

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

  37. kristina.io | @krstnfx | #devweek2019 37

  38. kristina.io | @krstnfx | #devweek2019 38

  39. kristina.io | @krstnfx | #devweek2019 39

  40. kristina.io | @krstnfx | #devweek2019 40

  41. kristina.io | @krstnfx | #devweek2019 41

  42. kristina.io | @krstnfx | #devweek2019 42 Device Crash Logs 1.

    Windows -> Devices and Simulators 2. Choose Devices tab 3. View device logs
  43. kristina.io | @krstnfx | #devweek2019 43 “Catch all” Breakpoints

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

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

  46. 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") } }
  47. 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") } }
  48. 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") } }
  49. kristina.io | @krstnfx | #devweek2019 49 struct Rooms: Codable {

    var name: String var id: Int }
  50. kristina.io | @krstnfx | #devweek2019 50 Custom Code Snippets 1.

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

    Use 4. Profit
  52. kristina.io | @krstnfx | #devweek2019 52

  53. kristina.io | @krstnfx | #devweek2019 53

  54. kristina.io | @krstnfx | #devweek2019 54

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

  56. kristina.io | @krstnfx | #devweek2019 56

  57. kristina.io | @krstnfx | #devweek2019 57

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

  59. kristina.io | @krstnfx | #devweek2019 59 > Your colleague is

    having a hard time debugging an animation in simulator. What do you suggest?
  60. kristina.io | @krstnfx | #devweek2019 60 Debug animations

  61. 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?
  62. kristina.io | @krstnfx | #devweek2019 62 Drag and Drop Media

    into simulator
  63. kristina.io | @krstnfx | #devweek2019 63 > What’s the easiest

    way to find all strings that look like email addresses in your app?
  64. kristina.io | @krstnfx | #devweek2019 64 Pattern Matching in Search

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

  66. 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?
  67. kristina.io | @krstnfx | #devweek2019 67 Search history

  68. 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?
  69. kristina.io | @krstnfx | #devweek2019 69 Multiple Cursors Option +

    drag (rectangular selection) Ctrl + shift + click (place multiple cursors)
  70. kristina.io | @krstnfx | #devweek2019 70 > How do you

    debug an issue where the root cause is poor network connectivity?
  71. kristina.io | @krstnfx | #devweek2019 71 Network link simulator

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

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

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

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

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

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

    spirit animal?
  78. kristina.io | @krstnfx | #devweek2019 78

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

  80. kristina.io | @krstnfx | #devweek2019 80

  81. kristina.io | @krstnfx | #devweek2019 81 456

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

    story Just kidding
  83. 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)
  84. 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
  85. 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
  86. 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
  87. 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
  88. kristina.io | @krstnfx | #devweek2019 88 Thank you! Questions? 8