Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SwiftGen
Search
USAMI Kosuke
August 31, 2016
Programming
0
1.2k
SwiftGen
http://kanmoba.connpass.com/event/37712/
USAMI Kosuke
August 31, 2016
Tweet
Share
More Decks by USAMI Kosuke
See All by USAMI Kosuke
Onsager代数とその周辺 / Onsager algebra tsudoi
usamik26
0
580
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
140
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
300
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
450
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
710
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
640
UICollectionView Compositional Layout
usamik26
0
720
Coding Swift with Visual Studio Code and Docker
usamik26
0
480
Swift Extension for Visual Studio Code
usamik26
2
970
Other Decks in Programming
See All in Programming
Pythonでもちょっとリッチな見た目のアプリを設計してみる
ueponx
1
480
CI改善もDatadogとともに
taumu
0
110
Software Architecture
hschwentner
6
2.1k
Writing documentation can be fun with plugin system
okuramasafumi
0
120
第3回 Snowflake 中部ユーザ会- dbt × Snowflake ハンズオン
hoto17296
4
360
昭和の職場からアジャイルの世界へ
kumagoro95
1
350
なぜイベント駆動が必要なのか - CQRS/ESで解く複雑系システムの課題 -
j5ik2o
7
2.5k
『品質』という言葉が嫌いな理由
korimu
0
160
Domain-Driven Transformation
hschwentner
2
1.9k
XStateを用いた堅牢なReact Components設計~複雑なClient Stateをシンプルに~ @React Tokyo ミートアップ #2
kfurusho
1
770
第3回関東Kaggler会_AtCoderはKaggleの役に立つ
chettub
3
890
Honoをフロントエンドで使う 3つのやり方
yusukebe
4
2.1k
Featured
See All Featured
A Tale of Four Properties
chriscoyier
158
23k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
How STYLIGHT went responsive
nonsquared
98
5.3k
Embracing the Ebb and Flow
colly
84
4.6k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
How to train your dragon (web standard)
notwaldorf
90
5.8k
Done Done
chrislema
182
16k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
YesSQL, Process and Tooling at Scale
rocio
171
14k
Facilitating Awesome Meetings
lara
51
6.2k
Transcript
SwiftGen Ӊࠤݟ ެี Fenrir Inc.
SwiftGen ͱ » ϦιʔεऔΓࠐΈπʔϧ » SwiftGen » R.swift » rdotm
ԿΛ͢Δπʔϧʁ » ΞϓϦͷը૾ςΩετͷѻָ͍͕ʹͳΔίʔυΛࣗಈੜͯ͘͠ ΕΔ // πʔϧͳ͠ͷ߹ let image = UIImage(named:
"banana") // SwiftGen Λͬͨ߹ let image = UIImage(asset: .Banana)
ରԠ͍ͯ͠ΔϦιʔε » ը૾ » จࣈྻʢϩʔΧϥΠζʣ » Storyboard » ৭ »
ϑΥϯτ
͍ํ » swiftgen images DIR » swiftgen strings FILE »
swiftgen storyboards DIR » swiftgen colors FILE » swiftgen fonts DIR » ࣮ߦ͢Δͱ Swift ιʔείʔυ͕ग़ྗ͞ΕΔ
ೖྗσʔλ » ը૾ : *.xcassets » จࣈྻ : *.strings »
Storyboard : *.storyboard » ৭ : ఆٛϑΝΠϧΛผ్༻ҙʢ*.json ͳͲʣ » ϑΥϯτ : *.ttf, *.otf ͳͲ
ར༻ଆͷίʔυ
Images let image = UIImage(asset: .Banana) let image = Asset.Banana.image
Strings let title = tr(.AlertTitle) let title = L10n.AlertTitle.string
Storyboards // ViewController let initialVC = StoryboardScene.Main.initialViewController() let loginVC =
StoryboardScene.Main.LoginViewController() // Segue performSegue(StoryboardSegue.Main.CreateAccount)
Colors let titleColor = UIColor(named: .Title) let titleColor = ColorName.Title.color
ϝϦοτ » Ϧιʔεࢦఆจࣈྻͷϛε͕ͳ͘ͳΔ » ίϯύΠϧ࣌ʹνΣοΫ͞ΕΔͨΊ » ิೖྗͰ͖ɺίʔυ͕ॻ͖͘͢ͳΔ ʢCocoa ౷తʹɺϦιʔεࢦఆจࣈྻͰهड़͓͖ͯ͠ɺ࣮ߦ࣌ʹ ղܾ͢Δํࣜɻѱ͍ͱݴΘͳ͍͕ϛε͕ͪ͠ʣ
ϝϦοτ (2) » Localizable.strings ࡞ͷ৺ཧతෛ୲ͷܰݮ » ίʔυ͕ॻ͖͘͢ͳΔͷ͔ͩΒ͓ͬͯ͜͏ͱ͍͏ؾ࣋ͪʹͳ Δ ʢLocalizableString Λॻ͘ͷ͕໘ʹͳͬͯɺιʔείʔυʹදࣔจࣈ
ྻΛॻ͍ͯ͠·͏͜ͱ͋ΔΑͶʁʣ
ੜίʔυΛݟͯΈΔ
Images : enum case enum Asset: String { case Banana
= "banana" case Apple = "apple" }
Image extension extension Image { convenience init!(asset: Asset) { self.init(named:
asset.rawValue) } } // ར༻ํ๏ let image = UIImage(asset: .Banana)
enum property enum Asset: String { var image: Image {
return Image(asset: self) } } // ར༻ํ๏ let image = Asset.Banana.image
ίʔυੜςϯϓϨʔτ
ඪ४ςϯϓϨʔτ » ඪ४ͰෳͷςϯϓϨʔτ͕༻ҙ͞Ε͍ͯΔ » swiftgen templates ͰҰཡͰ͖Δ » ྫ͑ Images
ͩͱ࣍ͷ2छྨ͕͋Δ » default » allvalues
ΧελϜςϯϓϨʔτ » ࣗͰΧελϜςϯϓϨʔτΛ࡞Ͱ͖Δ » ςϯϓϨʔτ Stencil Ͱهड़ » Mustache ͷ
Swift ൛ͷΑ͏ͳͷ » SwiftGen Ͱ֦ு͍ͯ͠Δ
ςϯϓϨʔτͷྫ enum {{enumName}}: String { {% for image in images
%} case {{image|swiftIdentifier}} = "{{image}}" {% endfor %} }
Tips
Tips (1) » Ϧιʔεมߋͷͨͼʹ SwiftGen Λ࣮ߦ͢Δͷ໘ » Xcode ͷ Build
Phase Ͱ࣮ߦͯ͠͠·͏ » Ϗϧυ࣌ʹίʔυࣗಈੜ͍ͭͰʹߦ͏
Tips (2) » CocoaPods ͰΠϯετʔϧ͢Δ͜ͱͰ͖Δ » ϥΠϒϥϦ͕Ճ͞ΕΔΘ͚Ͱͳ͘ɺswiftgen ίϚϯυ͕ϓϩ δΣΫτʹՃ͞ΕΔ »
Xcode ͷ Build Phase Ͱ࣮ߦ͢Δ߹ʹίϚϯυ͕࣮֬ʹଘࡏ͢ ΔͷͰศར
·ͱΊ : SwiftGen » Ϧιʔε͔ΒίʔυΛࣗಈੜͯ͘͠ΕΔ » Ϧιʔεࢦఆจࣈྻͷϛε͕ͳ͘ͳΓɺίʔυ͕ॻ͖͘͢ͳΔ » ੜίʔυඞཁʹԠͯ͡ΧελϚΠζͰ͖Δ »
Ϗϧυ࣌ʹࣗಈੜΛ͓ͯ͘͠ͱศར