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
880
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
250
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
700
Trace outside of stack trace
shotakashihara
11
2.2k
Other Decks in Technology
See All in Technology
JuliaTokaiとJuliaLangJaの紹介 for NGK2025S
antimon2
1
110
アジャイルチームが変化し続けるための組織文化とマネジメント・アプローチ / Agile management that enables ever-changing teams
kakehashi
3
3.3k
Docker Desktop で Docker を始めよう
zembutsu
PRO
0
140
技術に触れたり、顔を出そう
maruto
1
140
Alignment and Autonomy in Cybozu - 300人の開発組織でアラインメントと自律性を両立させるアジャイルな組織運営 / RSGT2025
ama_ch
1
2.3k
テストを書かないためのテスト/ Tests for not writing tests
sinsoku
1
170
When Windows Meets Kubernetes…
pichuang
0
300
Visual StudioとかIDE関連小ネタ話
kosmosebi
1
370
データ基盤におけるIaCの重要性とその運用
mtpooh
2
250
Copilotの力を実感!3ヶ月間の生成AI研修の試行錯誤&成功事例をご紹介。果たして得たものとは・・?
ktc_shiori
0
340
Oracle Base Database Service:サービス概要のご紹介
oracle4engineer
PRO
1
16k
ゼロからわかる!!AWSの構成図を書いてみようワークショップ 問題&解答解説 #デッカイギ #羽田デッカイギおつ
_mossann_t
0
1.5k
Featured
See All Featured
The Invisible Side of Design
smashingmag
299
50k
Side Projects
sachag
452
42k
Fireside Chat
paigeccino
34
3.1k
Navigating Team Friction
lara
183
15k
Documentation Writing (for coders)
carmenintech
67
4.5k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.2k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Measuring & Analyzing Core Web Vitals
bluesmoon
5
210
Testing 201, or: Great Expectations
jmmastey
41
7.2k
Gamification - CAS2011
davidbonilla
80
5.1k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.8k
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