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.1k
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
500
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
99
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
270
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
420
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
670
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
600
UICollectionView Compositional Layout
usamik26
0
650
Coding Swift with Visual Studio Code and Docker
usamik26
0
430
Swift Extension for Visual Studio Code
usamik26
2
860
Other Decks in Programming
See All in Programming
Progressive Web Apps for Rails developers
siaw23
2
530
PHPを書く理由、PHPを書いていて良い理由 / Reasons to write PHP and why it is good to write PHP
seike460
PRO
5
270
GitHub Copilot Workspace で我々のアプリ開発がどう変わるのか?
shuyakinjo
0
850
クラウドサービスの 利用コストを削減する技術 - 円安の真南風を感じて -
pyama86
3
240
What is TDD?
urakawa_jinsei
1
200
XP2024 っていう国際会議に行ってきたよの記 / XP2024 Conference Report
bonotake
4
160
Cohesion in Modeling and Design
mploed
3
180
Kubernetes上でOracle_Databaseの運用を楽にするOraOperatorの紹介
nnaka2992
0
150
CDKを活用した 大規模コンテナ移行 プロジェクトの紹介
yoyoyopg
0
230
AWS Lambda Web Adapterを活用する新しいサーバーレスの実装パターン
tmokmss
6
5.4k
sqlcを利用してsqlに型付けを
kamiyam
0
230
[KR] Server Driven Compose With Firebase
skydoves
1
120
Featured
See All Featured
Building Your Own Lightsaber
phodgson
102
6k
Adopting Sorbet at Scale
ufuk
73
8.9k
Building Better People: How to give real-time feedback that sticks.
wjessup
360
19k
Happy Clients
brianwarren
97
6.6k
How GitHub Uses GitHub to Build GitHub
holman
473
290k
Rails Girls Zürich Keynote
gr2m
93
13k
The Art of Programming - Codeland 2020
erikaheidi
50
13k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
32k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2k
Navigating Team Friction
lara
183
14k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
22k
A Tale of Four Properties
chriscoyier
155
22k
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 » Ϧιʔε͔ΒίʔυΛࣗಈੜͯ͘͠ΕΔ » Ϧιʔεࢦఆจࣈྻͷϛε͕ͳ͘ͳΓɺίʔυ͕ॻ͖͘͢ͳΔ » ੜίʔυඞཁʹԠͯ͡ΧελϚΠζͰ͖Δ »
Ϗϧυ࣌ʹࣗಈੜΛ͓ͯ͘͠ͱศར