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
530
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
110
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
280
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
430
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
690
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
610
UICollectionView Compositional Layout
usamik26
0
680
Coding Swift with Visual Studio Code and Docker
usamik26
0
450
Swift Extension for Visual Studio Code
usamik26
2
910
Other Decks in Programming
See All in Programming
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
140
Better Code Design in PHP
afilina
PRO
0
130
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
100
みんなでプロポーザルを書いてみた
yuriko1211
0
260
Click-free releases & the making of a CLI app
oheyadam
2
120
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
Jakarta EE meets AI
ivargrimstad
0
110
最新TCAキャッチアップ
0si43
0
190
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.8k
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
190
ヤプリ新卒SREの オンボーディング
masaki12
0
130
Featured
See All Featured
Building an army of robots
kneath
302
43k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
Designing for humans not robots
tammielis
250
25k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Speed Design
sergeychernyshev
25
620
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Site-Speed That Sticks
csswizardry
0
27
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Navigating Team Friction
lara
183
14k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Side Projects
sachag
452
42k
Designing the Hi-DPI Web
ddemaree
280
34k
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 » Ϧιʔε͔ΒίʔυΛࣗಈੜͯ͘͠ΕΔ » Ϧιʔεࢦఆจࣈྻͷϛε͕ͳ͘ͳΓɺίʔυ͕ॻ͖͘͢ͳΔ » ੜίʔυඞཁʹԠͯ͡ΧελϚΠζͰ͖Δ »
Ϗϧυ࣌ʹࣗಈੜΛ͓ͯ͘͠ͱศར