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

SwiftGen

 SwiftGen

USAMI Kosuke

August 31, 2016
Tweet

More Decks by USAMI Kosuke

Other Decks in Programming

Transcript

  1. ࢖͍ํ » swiftgen images DIR » swiftgen strings FILE »

    swiftgen storyboards DIR » swiftgen colors FILE » swiftgen fonts DIR » ࣮ߦ͢Δͱ Swift ιʔείʔυ͕ग़ྗ͞ΕΔ
  2. ೖྗσʔλ » ը૾ : *.xcassets » จࣈྻ : *.strings »

    Storyboard : *.storyboard » ৭ : ఆٛϑΝΠϧΛผ్༻ҙʢ*.json ͳͲʣ » ϑΥϯτ : *.ttf, *.otf ͳͲ
  3. Storyboards // ViewController let initialVC = StoryboardScene.Main.initialViewController() let loginVC =

    StoryboardScene.Main.LoginViewController() // Segue performSegue(StoryboardSegue.Main.CreateAccount)
  4. Images : enum case enum Asset: String { case Banana

    = "banana" case Apple = "apple" }
  5. Image extension extension Image { convenience init!(asset: Asset) { self.init(named:

    asset.rawValue) } } // ར༻ํ๏ let image = UIImage(asset: .Banana)
  6. enum property enum Asset: String { var image: Image {

    return Image(asset: self) } } // ར༻ํ๏ let image = Asset.Banana.image
  7. ςϯϓϨʔτͷྫ enum {{enumName}}: String { {% for image in images

    %} case {{image|swiftIdentifier}} = "{{image}}" {% endfor %} }
  8. Tips (1) » Ϧιʔεมߋͷͨͼʹ SwiftGen Λ࣮ߦ͢Δͷ͸໘౗ » Xcode ͷ Build

    Phase Ͱ࣮ߦͯ͠͠·͏ » Ϗϧυ࣌ʹίʔυࣗಈੜ੒΋͍ͭͰʹߦ͏