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
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
410
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
500
スクラムチームを立ち上げる〜チーム開発で得られたもの・得られなかったもの〜
ohnoeight
2
350
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
130
フルカイテン株式会社 採用資料
fullkaiten
0
40k
DMARC 対応の話 - MIXI CTO オフィスアワー #04
bbqallstars
1
160
ハイパーパラメータチューニングって何をしているの
toridori_dev
0
140
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
1
240
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
3
940
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
990
スクラム成熟度セルフチェックツールを作って得た学びとその活用法
coincheck_recruit
1
140
Amazon Personalizeのレコメンドシステム構築、実際何するの?〜大体10分で具体的なイメージをつかむ〜
kniino
1
100
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Happy Clients
brianwarren
98
6.7k
Site-Speed That Sticks
csswizardry
0
23
How STYLIGHT went responsive
nonsquared
95
5.2k
A Philosophy of Restraint
colly
203
16k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
89
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
The World Runs on Bad Software
bkeepers
PRO
65
11k
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