Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Xcode Survival Guide

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

Kristina Fox

February 20, 2019
Tweet

More Decks by Kristina Fox

Other Decks in Technology

Transcript

  1. 3

  2. 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() } }
  3. 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) } }
  4. 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) } }
  5. 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) } }
  6. kristina.io | @krstnfx | #devweek2019 34 User Defined Build Settings

    Project file -> Build Settings -> User-Defined Settings 02:49
  7. kristina.io | @krstnfx | #devweek2019 42 Device Crash Logs 1.

    Windows -> Devices and Simulators 2. Choose Devices tab 3. View device logs
  8. 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") } }
  9. 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") } }
  10. 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") } }
  11. kristina.io | @krstnfx | #devweek2019 50 Custom Code Snippets 1.

    Highlight code 2. Drag to code snippets window 3. Drop & fill completion shortcut
  12. kristina.io | @krstnfx | #devweek2019 59 > Your colleague is

    having a hard time debugging an animation in simulator. What do you suggest?
  13. 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?
  14. kristina.io | @krstnfx | #devweek2019 63 > What’s the easiest

    way to find all strings that look like email addresses in your app?
  15. 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?
  16. 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?
  17. kristina.io | @krstnfx | #devweek2019 69 Multiple Cursors Option +

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

    debug an issue where the root cause is poor network connectivity?
  19. 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)
  20. 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
  21. 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
  22. 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
  23. 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