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

R.swift - Statically typed resources for iOS

R.swift - Statically typed resources for iOS

Mathijs Kadijk presents R.swift at the September 2016 CocoaHeadsNL meetup. R.swift provides statically typed, autocompleted resources like images, fonts and segues in Swift projects.

Video of this presentation can be found at https://vimeo.com/185173151

Mathijs Kadijk

September 21, 2016
Tweet

More Decks by Mathijs Kadijk

Other Decks in Programming

Transcript

  1. So I wrote some more code: let icon = UIImage(named:

    "settings-icon") let title = NSLocalizedString("title", tableName: "Generic", comment: "") let storyboard = UIStoryboard(name: "Main", bundle: nil) let vc = storyboard .instantiateViewController(withIdentifier: "Setings") as? SettingsController vc.initialSettingsUrl = Bundle.main .url(forResource: "seed-data", withExtension: "json")
  2. No compile time checks let icon = UIImage(named: "small-gear") let

    title = NSLocalizedString("title", tableName: "Settings", comment: "") let storyboard = UIStoryboard(name: "Settings", bundle: nil) let vc = storyboard .instantiateInitialViewController() as? SettingsController vc.initialSettingsUrl = Bundle.main .url(forResource: "initial-settings", withExtension: "json")
  3. Converting to R.swift: let icon = UIImage(named: "small-gear") let title

    = NSLocalizedString("title", tableName: "Settings", comment: "") let storyboard = UIStoryboard(name: "Settings", bundle: nil) let vc = storyboard .instantiateInitialViewController() as? SettingsController vc.initialSettingsUrl = Bundle.main .url(forResource: "initial-settings", withExtension: "json")
  4. Converting to R.swift: let icon = R.image.smallGear() let title =

    NSLocalizedString("title", tableName: "Settings", comment: "") let storyboard = UIStoryboard(name: "Settings", bundle: nil) let vc = storyboard .instantiateInitialViewController() as? SettingsController vc.initialSettingsUrl = Bundle.main .url(forResource: "initial-settings", withExtension: "json")
  5. Converting to R.swift: let icon = R.image.smallGear() let title =

    R.string.settings.title() let storyboard = UIStoryboard(name: "Settings", bundle: nil) let vc = storyboard .instantiateInitialViewController() as? SettingsController vc.initialSettingsUrl = Bundle.main .url(forResource: "initial-settings", withExtension: "json")
  6. Converting to R.swift: let icon = R.image.smallGear() let title =

    R.string.settings.title() let vc = R.storyboard.settings.initialViewController() vc.initialSettingsUrl = Bundle.main .url(forResource: "initial-settings", withExtension: "json")
  7. Converting to R.swift: let icon = R.image.smallGear() let title =

    R.string.settings.title() let vc = R.storyboard.settings.initialViewController() vc.initialSettingsUrl = R.file.initialSettingsJson()
  8. Wide range of resources: · Images · Custom fonts ·

    Resource files · Reusable cells · Localized strings · Storyboards, segues & nibs