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
権威ドキュメントで振り返る2024 #年忘れセキュリティ2024
hirotomotaguchi
2
750
How to be an AWS Community Builder | 君もAWS Community Builderになろう!〜2024 冬 CB募集直前対策編?!〜
coosuke
PRO
2
2.8k
Opcodeを読んでいたら何故かphp-srcを読んでいた話
murashotaro
0
260
ブラックフライデーで購入したPixel9で、Gemini Nanoを動かしてみた
marchin1989
1
540
大幅アップデートされたRagas v0.2をキャッチアップ
os1ma
2
540
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
バクラクのドキュメント解析技術と実データにおける課題 / layerx-ccc-winter-2024
shimacos
2
1.1k
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
200
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
1
240
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
380
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
180
OpenAIの蒸留機能(Model Distillation)を使用して運用中のLLMのコストを削減する取り組み
pharma_x_tech
4
560
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Documentation Writing (for coders)
carmenintech
66
4.5k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Faster Mobile Websites
deanohume
305
30k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
RailsConf 2023
tenderlove
29
940
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
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