Dyld is responsible for locating and loading dynamic frameworks that a program needs at runtime and for linking the code in the libraries with the program. It also manages the symbols (names of variables and functions) in libraries and makes them available to the program.
Before any app launch code executes, dyld loads in all dynamic frameworks, which we characterize as
<early startup>
in Emerge flamegraphs. The more dynamic frameworks you add, the longer this process takes.App launch flamegraph showing `dyld` in startup path
We built a sample Swift app to demonstrate the role of dyld in app launch. One build of the app uses static frameworks and the other build uses the same frameworks linked dynamically. When we compare the app launch of the two builds, we see an 8.7% regression in app launch for the build using dynamic frameworks.
App launch comparison showing a regression in build with dynamic frameworks
By using dynamic libraries, programs can reduce the size of their app bundle, but potentially experience app launch regression compared to using static frameworks. Dyld is an essential component of the operating system that plays a vital role in allowing programs to use shared code and libraries. Apple's WWDC2022 talk on linking is a great resource to learn about the work Apple is doing to continually improve dyld.