How can I delay splash launch screen programmatically in Swift Xcode iOS How can I delay splash launch screen programmatically in Swift Xcode iOS xcode xcode

How can I delay splash launch screen programmatically in Swift Xcode iOS


Put one line of code in AppDelegate class -

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {        Thread.sleep(forTimeInterval: 3.0)        // Override point for customization after application launch.        return true    }


Would not recommending setting the entire application in a waiting state. If the application needs to do more work before finishing the watchdog could kill the application for taking too long time to start up.

Instead you could do something like this to delay the launch screen.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {        // Override point for customization after application launch.        window = UIWindow(frame: UIScreen.main.bounds)        window?.rootViewController = UIStoryboard(name: "LaunchScreen", bundle: nil).instantiateInitialViewController()        window?.makeKeyAndVisible()        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 3) {            self.window?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()        }        return true    }


Swift 4.x

It is Not a good practice to put your application to sleep!

Booting your App should be as fast as possible, so the Launch screen delay is something you do not want to use.

But, instead of sleeping you can run a loop during which the receiver processes data from all attached input sources:

This will prolong the launch-screen's visibility time.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {    // Override point for customization after application launch.    RunLoop.current.run(until: NSDate(timeIntervalSinceNow:1) as Date)    return true}