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
870
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
240
UI デザインシステム
shotakashihara
2
2.4k
アプリのログをチーム外で活用してもらうためにやったこと
shotakashihara
0
580
iOS エンジニアが KMM で2つの アプリのログイン処理を共通化した話
shotakashihara
1
670
iOS 14 からの Universal Links
shotakashihara
1
3.8k
iOSアプリ自動ログテストのススメ
shotakashihara
2
1.3k
デバイス管理を App Store Connect API でやってみよう
shotakashihara
2
680
Trace outside of stack trace
shotakashihara
11
2.2k
Other Decks in Technology
See All in Technology
ずっと昔に Star をつけたはずの思い出せない GitHub リポジトリを見つけたい!
rokuosan
0
150
開発生産性向上! 育成を「改善」と捉えるエンジニア育成戦略
shoota
1
230
第3回Snowflake女子会_LT登壇資料(合成データ)_Taro_CCCMK
tarotaro0129
0
180
KubeCon NA 2024 Recap: How to Move from Ingress to Gateway API with Minimal Hassle
ysakotch
0
200
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
210
ブラックフライデーで購入したPixel9で、Gemini Nanoを動かしてみた
marchin1989
1
520
フロントエンド設計にモブ設計を導入してみた / 20241212_cloudsign_TechFrontMeetup
bengo4com
0
1.9k
.NET 9 のパフォーマンス改善
nenonaninu
0
690
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
470
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
150
サイバー攻撃を想定したセキュリティガイドライン 策定とASM及びCNAPPの活用方法
syoshie
3
1.2k
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
222
9k
A Tale of Four Properties
chriscoyier
157
23k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
170
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Code Reviewing Like a Champion
maltzj
520
39k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Speed Design
sergeychernyshev
25
670
Into the Great Unknown - MozCon
thekraken
33
1.5k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
GraphQLとの向き合い方2022年版
quramy
44
13k
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