Launch phases
System InterfaceSeparate in two phases:
DYLD3Dynamic Linker: loads shared libraries and frameworks
libSystem Init: initializes app low level components
Static Runtime init
Separate in two phases:
Initializes the language runtime (objc/swift)
Expose dedicate initialization API in frameworks.
Reduce impact to launch by avoiding
+[Class load]Use
[Class initialize]to lazily conduct static initialization
UIKit init
This is when the system initializes
UIApplicationandUIApplicationDelegate
Application init
Invokes
UIApplicationDelegateapp lifecycle callbacksUIApplicationWillFinishLaunching/didFinish/DidBecomeActive(iOS 13 and later) We now get UISceneDelegate UI lifecycle callbacks for each scene:
willConnectToSession:,sceneWillEnterForeground:,sceneDidBecomeActive.
Initial Frame Render
this is when the app views are created, their layout is performed, and they’re drawn.
loadViewviewDidLoadlayoutSubviewstips:
reduce the number of views launched at the beginning
flat view hierarchies and lazily load views not needed during launch
Extended
apps specific logic
How to test our app launch time
We have an instrument entirely dedicated to analyze launch times: this will split the app launch in all the sections seen above and highlight our code that executes during this phase.
The new XCTest Metrics is also a very useful and lightweight way to make sure to not incur in some huge slowdowns during development.
