Execute Code in Launch Screen UPDATED
It is not possible to write any custom class/code for the launchscreen xib/storyboard files. We can only design using resource files.
Swift - Execute code on LaunchScreen
As you wrote, LaunchScreen is there before your app is ready and it implies that you can't execute your code in this time.
To achieve something similar, copy & paste content of your LaunchScreen into your initial view controller in your Main storyboard (or whatever you do use) and launch your request in initial view controller and then transition to any other view controller.
User is not going to notice LaunchScreen -> Main transition.
Purpose of LaunchScreen is to just replace splash images with something better where you can use auto layout for example, ... In other words, to minimize your work, so, you're not forced to create splash screen for every device screen size, etc. But you are not allowed to run any logic in LaunchScreen.
Execute code in Launch Screen
No, it's not possible.
When launch screen is being displayed your app will be in loading state.
Even the - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
will not be completely executed while the launch screen is displayed.
So it's clear that, you don't have any access to your app and so at this point you can't execute any code.
Is there any way to code the LaunchScreen programmatically
No, The launch screen is shown before your app starts executing in order to provide a transition from the Springboard to your app while it is loading.
You can either use a fixed image or you can use a simple storyboard scene using only standard, static UI elements - labels & images.
This storyboard scene is actually loaded and displayed by the OS, so it would be a security risk to allow your code to execute in that context.
iOS Launch screens with logic
No, not possible. The launch screen is not rendered by your app, but by the system, so it is static.
Note that the launch screen is is not a fully customizable view controller. You cannot specify a custom class name in the storyboard and expect the system to give you the option to execute code at this stage by calling viewDidLoad. Remember, the app hasn’t launched yet.
(According to this site)
Also it appears that you cannot change the launch image programatically, as discussed in this question.
Replace Launch screen text on each app login
You can't assign custom VC to that launch (only static images or text dragged from Object Library ) , if you want to make splash make it in the rootVC then navigate to the mainVC
iOS Launch screen code not running
You're not doing anything wrong.
No code is associated with the launch screen. You can't run any logic. It is purely there so that you can use AutoLayout to layout the launch screens for different sizes of device.
Related Topics
How to Create a Swift Date Object
How Would I Tint an Image Programmatically on Ios
Ios9 Getting Error "An Ssl Error Has Occurred and a Secure Connection to the Server Cannot Be Made"
Getting All Cookies from Wkwebview
Navigation Bar With Uiimage For Title
How to Change Multiplier Property For Nslayoutconstraint
Detect iOS App Entering Background
How to Debug iOS 8 Extensions With Nslog
Add Placeholder Text Inside Uitextview in Swift
Add "...Read More" to the End of Uilabel
Uicollectionview Inside a Uitableviewcell - Dynamic Height
Swrevealviewcontroller Without Using Navigationcontroller
How to Get a Plist as a Dictionary in Swift
Cordova App Not Displaying Correctly on Iphone X (Simulator)
Getting List of Files in Documents Folder
Detecting a Point in a Mkpolygon Broke with iOS7 (Cgpathcontainspoint)