How do you reduce launch time? What is pre-main?
The point
Launch has two phases:
- Pre-main — everything before
main()is called: the kernel creates the process, dyld loads the executable and dynamic libraries, applies fixups (since iOS 15 chained fixups instead of separate rebase/bind — faster and lazier), registers Obj-C classes and categories, runs+loadand C++ static initializers. Your code barely participates here — only+loadand global initializers. - Post-main —
UIApplicationMain,didFinishLaunching, scene creation, the firstlayoutSubviews/bodyand the first frame. Apple targets a first frame within 400 ms (cold start).
Separately: prewarming (iOS 15+) — the system may launch the process in advance and pause it after pre-main, so pre-main is already paid for at the "real" launch. This matters for measurement: the process uptime from ProcessInfo is not the time the user saw.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep