Slide 1

Slide 1 text

SwiftGen Ӊࠤݟ ެี Fenrir Inc.

Slide 2

Slide 2 text

SwiftGen ͱ͸ » ϦιʔεऔΓࠐΈπʔϧ » SwiftGen » R.swift » rdotm

Slide 3

Slide 3 text

ԿΛ͢Δπʔϧʁ » ΞϓϦ಺ͷը૾΍ςΩετͷѻָ͍͕ʹͳΔίʔυΛࣗಈੜ੒ͯ͘͠ ΕΔ // πʔϧͳ͠ͷ৔߹ let image = UIImage(named: "banana") // SwiftGen Λ࢖ͬͨ৔߹ let image = UIImage(asset: .Banana)

Slide 4

Slide 4 text

ରԠ͍ͯ͠ΔϦιʔε » ը૾ » จࣈྻʢϩʔΧϥΠζʣ » Storyboard » ৭ » ϑΥϯτ

Slide 5

Slide 5 text

࢖͍ํ » swiftgen images DIR » swiftgen strings FILE » swiftgen storyboards DIR » swiftgen colors FILE » swiftgen fonts DIR » ࣮ߦ͢Δͱ Swift ιʔείʔυ͕ग़ྗ͞ΕΔ

Slide 6

Slide 6 text

ೖྗσʔλ » ը૾ : *.xcassets » จࣈྻ : *.strings » Storyboard : *.storyboard » ৭ : ఆٛϑΝΠϧΛผ్༻ҙʢ*.json ͳͲʣ » ϑΥϯτ : *.ttf, *.otf ͳͲ

Slide 7

Slide 7 text

ར༻ଆͷίʔυ

Slide 8

Slide 8 text

Images let image = UIImage(asset: .Banana) let image = Asset.Banana.image

Slide 9

Slide 9 text

Strings let title = tr(.AlertTitle) let title = L10n.AlertTitle.string

Slide 10

Slide 10 text

Storyboards // ViewController let initialVC = StoryboardScene.Main.initialViewController() let loginVC = StoryboardScene.Main.LoginViewController() // Segue performSegue(StoryboardSegue.Main.CreateAccount)

Slide 11

Slide 11 text

Colors let titleColor = UIColor(named: .Title) let titleColor = ColorName.Title.color

Slide 12

Slide 12 text

ϝϦοτ » Ϧιʔεࢦఆจࣈྻͷϛε͕ͳ͘ͳΔ » ίϯύΠϧ࣌ʹνΣοΫ͞ΕΔͨΊ » ิ׬ೖྗ΋Ͱ͖ɺίʔυ͕ॻ͖΍͘͢ͳΔ ʢCocoa ͸఻౷తʹɺϦιʔεࢦఆ͸จࣈྻͰهड़͓͖ͯ͠ɺ࣮ߦ࣌ʹ ղܾ͢Δํࣜɻѱ͍ͱ͸ݴΘͳ͍͕ϛε͕ͪ͠ʣ

Slide 13

Slide 13 text

ϝϦοτ (2) » Localizable.strings ࡞੒ͷ৺ཧతෛ୲ͷܰݮ » ίʔυ͕ॻ͖΍͘͢ͳΔͷ͔ͩΒ΍͓ͬͯ͜͏ͱ͍͏ؾ࣋ͪʹͳ Δ ʢLocalizableString Λॻ͘ͷ͕໘౗ʹͳͬͯɺιʔείʔυʹදࣔจࣈ ྻΛ௚઀ॻ͍ͯ͠·͏͜ͱ͋ΔΑͶʁʣ

Slide 14

Slide 14 text

ੜ੒ίʔυΛݟͯΈΔ

Slide 15

Slide 15 text

Images : enum case enum Asset: String { case Banana = "banana" case Apple = "apple" }

Slide 16

Slide 16 text

Image extension extension Image { convenience init!(asset: Asset) { self.init(named: asset.rawValue) } } // ར༻ํ๏ let image = UIImage(asset: .Banana)

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

ίʔυੜ੒ςϯϓϨʔτ

Slide 19

Slide 19 text

ඪ४ςϯϓϨʔτ » ඪ४Ͱෳ਺ͷςϯϓϨʔτ͕༻ҙ͞Ε͍ͯΔ » swiftgen templates ͰҰཡͰ͖Δ » ྫ͑͹ Images ͩͱ࣍ͷ2छྨ͕͋Δ » default » allvalues

Slide 20

Slide 20 text

ΧελϜςϯϓϨʔτ » ࣗ෼ͰΧελϜςϯϓϨʔτΛ࡞੒Ͱ͖Δ » ςϯϓϨʔτ͸ Stencil Ͱهड़ » Mustache ͷ Swift ൛ͷΑ͏ͳ΋ͷ » SwiftGen Ͱ֦ு͍ͯ͠Δ

Slide 21

Slide 21 text

ςϯϓϨʔτͷྫ enum {{enumName}}: String { {% for image in images %} case {{image|swiftIdentifier}} = "{{image}}" {% endfor %} }

Slide 22

Slide 22 text

Tips

Slide 23

Slide 23 text

Tips (1) » Ϧιʔεมߋͷͨͼʹ SwiftGen Λ࣮ߦ͢Δͷ͸໘౗ » Xcode ͷ Build Phase Ͱ࣮ߦͯ͠͠·͏ » Ϗϧυ࣌ʹίʔυࣗಈੜ੒΋͍ͭͰʹߦ͏

Slide 24

Slide 24 text

Tips (2) » CocoaPods ͰΠϯετʔϧ͢Δ͜ͱ΋Ͱ͖Δ » ϥΠϒϥϦ͕௥Ճ͞ΕΔΘ͚Ͱ͸ͳ͘ɺswiftgen ίϚϯυ͕ϓϩ δΣΫτ಺ʹ௥Ճ͞ΕΔ » Xcode ͷ Build Phase Ͱ࣮ߦ͢Δ৔߹ʹίϚϯυ͕࣮֬ʹଘࡏ͢ ΔͷͰศར

Slide 25

Slide 25 text

·ͱΊ : SwiftGen » Ϧιʔε͔ΒίʔυΛࣗಈੜ੒ͯ͘͠ΕΔ » Ϧιʔεࢦఆจࣈྻͷϛε͕ͳ͘ͳΓɺίʔυ͕ॻ͖΍͘͢ͳΔ » ੜ੒ίʔυ͸ඞཁʹԠͯ͡ΧελϚΠζͰ͖Δ » Ϗϧυ࣌ʹࣗಈੜ੒Λ͓ͯ͘͠ͱศར