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
App startup time with Dynamic/Static frameworks
Search
Shota Kashihara
March 19, 2019
Technology
4
860
App startup time with Dynamic/Static frameworks
Shota Kashihara
March 19, 2019
Tweet
Share
More Decks by Shota Kashihara
See All by Shota Kashihara
ふりかえり “Demystify SwiftUI”
shotakashihara
0
230
UI デザインシステム
shotakashihara
2
2.3k
アプリのログをチーム外で活用してもらうためにやったこと
shotakashihara
0
570
iOS エンジニアが KMM で2つの アプリのログイン処理を共通化した話
shotakashihara
1
660
iOS 14 からの Universal Links
shotakashihara
1
3.8k
iOSアプリ自動ログテストのススメ
shotakashihara
2
1.3k
デバイス管理を App Store Connect API でやってみよう
shotakashihara
2
660
Trace outside of stack trace
shotakashihara
12
2.2k
Other Decks in Technology
See All in Technology
飲食店データの分析事例とそれを支えるデータ基盤
kimujun
0
160
CDCL による厳密解法を採用した MILP ソルバー
imai448
3
140
VideoMamba: State Space Model for Efficient Video Understanding
chou500
0
190
組織成長を加速させるオンボーディングの取り組み
sudoakiy
2
210
Application Development WG Intro at AppDeveloperCon
salaboy
0
190
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.5k
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
3
630
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
130
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
110
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
870
AGIについてChatGPTに聞いてみた
blueb
0
130
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
6
660
Featured
See All Featured
Embracing the Ebb and Flow
colly
84
4.5k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Become a Pro
speakerdeck
PRO
25
5k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
Bash Introduction
62gerente
608
210k
We Have a Design System, Now What?
morganepeng
50
7.2k
Transcript
©2019 Wantedly, Inc. App startup time with Dynamic/Static frameworks try!
Swift Pre Talk 2019 Mar 19, 2019 - @ShotaKashihara
©2019 Wantedly, Inc. Shota Kashihara ɾWantedly People ɾiOS ɾSwift/Double base
ɾTwitter: @oakland76 ɾGitHub: @ShotaKashihara
©2019 Wantedly, Inc. ɾXcode ͱ Frameworks ͷྺ࢙ ɾΞϓϦͷىಈͱ Frameworks ͷؔ
ɾFrameworks ͷߏΛߟ͑Δ ࠓ͢͜ͱ
©2019 Wantedly, Inc. Xcode ͱ Frameworks ͷྺ࢙
©2019 Wantedly, Inc. Xcode ͱ Frameworks ͷྺ࢙ Dynamic/Static Framework Λ
͓͞Β͍
©2019 Wantedly, Inc. Xcode ͱ Frameworks ͷྺ࢙ Xcode 5 #2013
ɹɾOnly Static Library (Obj-C) Dynamic/Static Framework Λ ͓͞Β͍
©2019 Wantedly, Inc. Xcode ͱ Frameworks ͷྺ࢙ Xcode 5 #2013
ɹɾOnly Static Library (Obj-C) Xcode 6 #2014 ɹɾSupport embedded frameworks (Dynamic Library) Dynamic/Static Framework Λ ͓͞Β͍
©2019 Wantedly, Inc. Xcode ͱ Frameworks ͷྺ࢙ Xcode 5 #2013
ɹɾOnly Static Library (Obj-C) Xcode 6 #2014 ɹɾSupport embedded frameworks (Dynamic Library) Xcode 9 #2017 ɹɾSupport static library with Swift ɹɹɾCocoa Pods (v1.5.0), Carthage (v0.30.1) ʹͯ ରԠࡁ Dynamic/Static Framework Λ ͓͞Β͍
©2019 Wantedly, Inc. Dynamic/Static Framework
©2019 Wantedly, Inc. Framework ֦ுࢠ .framework ɾϥΠϒϥϦ ɾ(όϯυϧ) ɹɾNib ɹɾը૾
ɹɾϔομʔϑΝΠϧ ͳͲΛ·ͱΊͨϑΥϧμ Dynamic/Static Framework
©2019 Wantedly, Inc. Dynamic Framework .framework ɾಈతϥΠϒϥϦ (.dylib, or ֦ுࢠͳ͠)
ɹΛؚΜͩ Framework Dynamic/Static Framework
©2019 Wantedly, Inc. Dynamic Framework .framework ɾಈతϥΠϒϥϦ (.dylib, or ֦ுࢠͳ͠)
ɹΛؚΜͩ Framework ɾArchive ɹɾ<YourApp>/Frameworks/ Լʹ ɹɹ.framework ͷ··ίϐʔ Dynamic/Static Framework
©2019 Wantedly, Inc. Static Framework .framework ɾ੩తϥΠϒϥϦ (.a, or ֦ுࢠͳ͠)
ɹΛؚΜͩ Framework Dynamic/Static Framework
©2019 Wantedly, Inc. Static Framework .framework ɹ ɾArchive ɹɾ੩తϥΠϒϥϦίϯύΠϧ࣌ʹ੩తϦϯΧʹΑͬͯɺ ɹɹ࣮ߦՄೳϑΝΠϧʹؚ·ΕΔ(୯ҰͷϑΝΠϧʹͳΔ)
ɹɾϦιʔεϑΝΠϧΞϓϦέʔγϣϯԼʹίϐʔͯ͠ɺ ɹɹ࣮ߦՄೳϑΝΠϧ͔Βݟ͑Δঢ়ଶʹ͢Δඞཁ͋Γ Dynamic/Static Framework ← Static Library ίϯύΠϧͰ ࣮ߦՄೳϑΝΠϧͷҰ෦ʹͳΔ ɾ੩తϥΠϒϥϦ (.a, or ֦ுࢠͳ͠) ɹΛؚΜͩ Framework
©2019 Wantedly, Inc. Dynamic Library ͷ 2ͭͷಛ ɾDynamic Linking ɾDynamic
Loading Dynamic/Static Framework
©2019 Wantedly, Inc. Dynamic Linking ɾΞϓϦ࣮ߦ࣌ʹϦϯΫ͕ߦΘΕΔ͜ͱ ɾ࣮ߦՄೳϑΝΠϧΛখ͘͞อͭ͜ͱ͕Ͱ͖Δ Dynamic/Static Framework
©2019 Wantedly, Inc. Dynamic Loading ɾ`dlopen()` ɾΞϓϦىಈ࣌Ͱͳ͘ɺඞཁͳͱ͖ʹϩʔυΛ࢝ΊΔ͜ͱ͕Ͱ͖Δ ɾiOS Ͱ͍ͬͯΔ໘Λ͋·Γݟͨ͜ͱ͕ͳ͍ Dynamic/Static
Framework
©2019 Wantedly, Inc. ΞϓϦͷىಈʹͲ͏͍͏ϑϩʔ͕͋Δ͔
©2019 Wantedly, Inc. exec() to main()
©2019 Wantedly, Inc. exec() to main() ΞϓϦ্ཱ͕͕ͪΔ·ͰʹཪଆͰى͖͍ͯΔ͜ͱ ※ WWDC 2016
(Optimizing App Startup Time) ʹͯݴٴ͞ΕͨςʔϚ exec() to main()
©2019 Wantedly, Inc. exec() 1. Kernel maps your application into
new address space 2. Kernel loads helper program 3. Dyld runs in-process exec() to main()
©2019 Wantedly, Inc. exec() 1. Kernel maps your application into
new address space 2. Kernel loads helper program 3. Dyld runs in-process exec() to main()
©2019 Wantedly, Inc. exec() 1. Kernel maps your application into
new address space 2. Kernel loads helper program 3. Dyld runs in-process exec() to main()
©2019 Wantedly, Inc. exec() 1. Kernel maps your application into
new address space 2. Kernel loads helper program 3. Dyld runs in-process exec() to main()
©2019 Wantedly, Inc. exec() 1. Kernel maps your application into
new address space 2. Kernel loads helper program 3. Dyld runs in-process Dyld: ࣮ߦ࣌ʹ dynamic library ΛಡΈࠐΉϓϩηεͷ͜ͱ exec() to main()
©2019 Wantedly, Inc. Dyld Steps 1. Map all dependent dylibs,
recurse 2. Rebase all images 3. Bind all images 4. ObjC prepare images 5. Run initializers exec() to main()
©2019 Wantedly, Inc. Dyld Steps 1. Map all dependent dylibs,
recurse 2. Rebase all images 3. Bind all images 4. ObjC prepare images 5. Run initializers exec() to main()
©2019 Wantedly, Inc. Dyld Steps 1. Map all dependent dylibs,
recurse 2. Rebase all images 3. Bind all images 4. ObjC prepare images 5. Run initializers exec() to main()
©2019 Wantedly, Inc. Dyld Steps 1. Map all dependent dylibs,
recurse 2. Rebase all images 3. Bind all images 4. ObjC prepare images 5. Run initializers exec() to main() ͜ΕΒ͕ Dynamic Framework ͷ͚ͩ࠶ؼ͢Δ
©2019 Wantedly, Inc. Dyld Steps ͜͜ʹͲΕ͘Β͍ͷ͕͔͔͍࣌ؒͬͯΔ͔ΛݟΔ exec() to main()
©2019 Wantedly, Inc. DYLD_PRINT_STATISTICS exec() to main()
©2019 Wantedly, Inc. DYLD_PRINT_STATISTICS exec() to main() ΞϓϦΛ্ཱͪ͛Δͱ main() ·Ͱʹ
Dyld ʹ͔͔͕ͬͨ࣌ؒදࣔ
©2019 Wantedly, Inc. exec() to main() ɾΞϓϦͷىಈ࣌ʹ Dyld ͕࠶ؼతʹ Framework
ΛϝϞϦʹஔ͢Δ ɾDynamic Framework ͷ͚ͩΦʔόʔϔου͕૿͑Δ ɹ exec() to main()
©2019 Wantedly, Inc. exec() to main() ɾΞϓϦͷىಈ࣌ʹ Dyld ͕࠶ؼతʹ Framework
ΛϝϞϦʹஔ͢Δ ɾDynamic Framework ͷ͚ͩΦʔόʔϔου͕૿͑Δ ɹ ɹˠ ෳͷ Dynamic Frameworks Λ Static Library ͱͯ͠Ϗϧυͯ͠ɺ ɹɹ ͦΕΒΛ·ͱΊͨ Dynamic Frameworks Λ࡞Δ exec() to main()
©2019 Wantedly, Inc. ΞϓϦ ͷߏ Domain.framework Main.app Watch.app C.framework B.framework
(3rd party) A.framework
©2019 Wantedly, Inc. ΞϓϦ ͷߏ Domain.framework Main.app Watch.app Umbrella frameworks
C.framework B.framework (3rd party) A.framework
©2019 Wantedly, Inc. ΞϓϦ ͷߏ Domain.framework Main.app Watch.app Umbrella frameworks
C.framework B.framework (3rd party) A.framework Static linking
©2019 Wantedly, Inc. ·ͱΊ
©2019 Wantedly, Inc. Summary ɾDynamic frameworks ͕૿͑Δͱ Dyld ͷίετ͕͔͔Δ ɾΞϓϦͷىಈ͕ؾʹͳͬͨΒ
DYLD_PRINT_STATISTICS ΦϓγϣϯͰ ɹDynamic Library ͷϩʔυʹ͔͔͍ͬͯΔ࣌ؒΛݟͯΈΑ͏ ɾDynamic frameworks Λ Static Frameworks ʹஔ͖͑ͯ ɹDyld ͷίετΛݮΒ͢͜ͱબࢶͷҰͭ App startup time with Dynamic/Static frameworks
©2019 Wantedly, Inc. Have a nice try! Swift day