使用applicationDidFinishLaunching(_:)有哪些负面影响?官方为何建议替换?
applicationDidFinishLaunching(_:) & Its Downsides Great question! This is a classic piece of iOS launch process history—Apple first recommended replacing applicationDidFinishLaunching(_:) with the two split methods back in iOS 3, well before Swift even existed. While it’s not formally marked as deprecated, the company has made it clear it’s not the way forward, and here’s what you risk by sticking with it:
1. No Control Over Critical Launch Stages
The old method lumps all post-launch initialization into a single callback, but the two new methods split the launch process into two distinct phases:
application(_:willFinishLaunchingWithOptions:)fires after system core setup (like window initialization) but before UI rendering and third-party service setup. This is the ideal spot for lightweight, foundational setup (e.g., configuring core SDKs that don’t depend on UI).application(_:didFinishLaunchingWithOptions:)fires once all system initialization is complete, right before the app becomes active. This is where you should handle UI-related setup or heavier operations that need the full system environment.
Using applicationDidFinishLaunching(_:) forces you to mix these two types of logic together. You might end up running heavy UI tasks too early (slowing down launch) or delaying critical core setup until after it’s needed—leading to bugs or performance hits you can’t easily debug.
2. Poor Compatibility with Modern iOS Features
As iOS has grown, Apple has added countless extensions (like Notification Service Extensions, Widgets) and lifecycle features (like Scene Delegates in iOS 13). The split launch methods were designed to work seamlessly with these new systems:
- For extensions, the launch flow of the main app needs to sync with extension initialization logic—something the old method wasn’t built to handle. Using it can lead to mismatched states between your main app and extensions, causing them to fail or behave unpredictably.
- With Scene Delegates, multi-window apps have more complex lifecycle triggers.
applicationDidFinishLaunching(_:)doesn’t align with scene-specific launch events, leading to race conditions or incorrect state management when your app wakes from the background or creates a new window.
3. Future-Proofing Risks
While applicationDidFinishLaunching(_:) still works today, Apple has stopped investing in it. All new launch-related features, performance optimizations, and bug fixes are tied to the split methods. It’s only a matter of time before Apple formally deprecates the old method, and migrating your code later will be more painful than doing it now—especially if your app has grown to rely on tangled initialization logic in that single callback.
To wrap it up: the old method was a relic of simpler iOS days, and the split methods give you the precision, compatibility, and future-proofing you need for modern apps.
内容的提问来源于stack exchange,提问作者Fogmeister

