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
How mixi2 Uses TiDB for SNS Scalability and Performance
kanmo
29
11k
第3回 Snowflake 中部ユーザ会- dbt × Snowflake ハンズオン
hoto17296
4
360
『GO』アプリ データ基盤のログ収集システムコスト削減
mot_techtalk
0
110
Unity Android XR入門
sakutama_11
0
140
CI改善もDatadogとともに
taumu
0
110
sappoRo.R #12 初心者セッション
kosugitti
0
230
Compose でデザインと実装の差異を減らすための取り組み
oidy
1
300
『GO』アプリ バックエンドサーバのコスト削減
mot_techtalk
0
130
Pythonでもちょっとリッチな見た目のアプリを設計してみる
ueponx
1
480
テストをしないQAエンジニアは何をしているか?
nealle
0
130
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
270
GAEログのコスト削減
mot_techtalk
0
110
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
A Philosophy of Restraint
colly
203
16k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
How to train your dragon (web standard)
notwaldorf
90
5.8k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
Visualization
eitanlees
146
15k
Scaling GitHub
holman
459
140k
Documentation Writing (for coders)
carmenintech
67
4.6k
What's in a price? How to price your products and services
michaelherold
244
12k
It's Worth the Effort
3n
184
28k
Practical Orchestrator
shlominoach
186
10k
Designing Experiences People Love
moore
139
23k
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 » Ϧιʔε͔ΒίʔυΛࣗಈੜͯ͘͠ΕΔ » Ϧιʔεࢦఆจࣈྻͷϛε͕ͳ͘ͳΓɺίʔυ͕ॻ͖͘͢ͳΔ » ੜίʔυඞཁʹԠͯ͡ΧελϚΠζͰ͖Δ »
Ϗϧυ࣌ʹࣗಈੜΛ͓ͯ͘͠ͱศར