SwiftGen
by
USAMI Kosuke
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
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 » Ϧιʔε͔ΒίʔυΛࣗಈੜͯ͘͠ΕΔ » Ϧιʔεࢦఆจࣈྻͷϛε͕ͳ͘ͳΓɺίʔυ͕ॻ͖͘͢ͳΔ » ੜίʔυඞཁʹԠͯ͡ΧελϚΠζͰ͖Δ » Ϗϧυ࣌ʹࣗಈੜΛ͓ͯ͘͠ͱศར