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
600
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
160
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
310
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
460
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
720
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
650
UICollectionView Compositional Layout
usamik26
0
750
Coding Swift with Visual Studio Code and Docker
usamik26
0
490
Swift Extension for Visual Studio Code
usamik26
2
1k
Other Decks in Programming
See All in Programming
S3静的ホスティング+Next.js静的エクスポート で格安webアプリ構築
iharuoru
0
190
フロントエンドテストの育て方
quramy
8
2.2k
マルチアカウント環境での、そこまでがんばらない RI/SP 運用設計
wa6sn
0
220
本当だってば!俺もTRICK 2022に入賞してたんだってば!
jinroq
0
180
PHPでお金を扱う時、終わりのない 謎の1円調査の旅にでなくて済む方法
nakka
3
960
いまさら聞けない生成AI入門: 「生成AIを高速キャッチアップ」
soh9834
11
3.3k
Scala 3 で GLSL のための c-like-for を実装してみた
exoego
1
170
snacks.nvim内のセットアップ不要なプラグインを紹介 / introduce_snacks_nvim
uhooi
0
310
アーキテクトと美学 / Architecture and Aesthetics
nrslib
12
2.9k
バックエンドNode.js × フロントエンドDeno で開発して得られた知見
ayame113
4
1.2k
requirements with math
moony
0
510
OpenTelemetryを活用したObservability入門 / Introduction to Observability with OpenTelemetry
seike460
PRO
0
200
Featured
See All Featured
Statistics for Hackers
jakevdp
797
220k
Mobile First: as difficult as doing things right
swwweet
223
9.5k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.2k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
12
1.4k
Unsuck your backbone
ammeep
669
57k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
Building a Modern Day E-commerce SEO Strategy
aleyda
39
7.2k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
28
2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
Bash Introduction
62gerente
611
210k
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 » Ϧιʔε͔ΒίʔυΛࣗಈੜͯ͘͠ΕΔ » Ϧιʔεࢦఆจࣈྻͷϛε͕ͳ͘ͳΓɺίʔυ͕ॻ͖͘͢ͳΔ » ੜίʔυඞཁʹԠͯ͡ΧελϚΠζͰ͖Δ »
Ϗϧυ࣌ʹࣗಈੜΛ͓ͯ͘͠ͱศར