Trying to programmatically set the initially view controller in AppDelegate's didFinishLaunchingWithOptions(..) function - followed the answers here and here, but running into the problem where when debugging instead of showing the "Home" VC, a black screen loads instead. I have tried to look for answers to the "black screen" issue that others have experienced, but no luck.
Here is my AppDelegate's didFinishLaunchingWithOptions :
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
let frame = UIScreen.main.bounds
let window = UIWindow(frame: frame)
let storyBoard : UIStoryboard = UIStoryboard(name: "Home", bundle: nil)
let homeVC = storyBoard.instantiateViewController(identifier: "Home")
window.rootViewController = homeVC
window.makeKeyAndVisible()
return true
}
My "Home" VC in the "Home" Storyboard has "Is Initial View Controller" disabled/unchecked.
My Project's "Main Interface" is left empty, under the "Deployment Info" section of "General" settings.
I can see that my "Home" VC's viewDidLoad() override function loads all the way through - but, the Storyboard itself does not load (is white), before the black screen is produced.
Help? Not sure what else may be relevant.
// Home.swift:
import Foundation
import UIKit
import Firebase
class Home: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
print("Something!")
self.view.backgroundColor = .green
}
}
Console output:
<Warning>: Please set a value for FacebookAutoLogAppEventsEnabled. Set the flag to TRUE if you want to collect app install, app launch and in-app purchase events automatically. To request user consent before collecting data, set the flag value to FALSE, then change to TRUE once user consent is received. Learn more: https://developers.facebook.com/docs/app-events/getting-started-app-events-ios#disable-auto-events.
<Warning>: You haven't set a value for FacebookAdvertiserIDCollectionEnabled. Set the flag to TRUE if you want to collect Advertiser ID for better advertising and analytics results. To request user consent before collecting data, set the flag value to FALSE, then change to TRUE once user consent is received. Learn more: https://developers.facebook.com/docs/app-events/getting-started-app-events-ios#disable-auto-events.
- <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
6.10.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60103000 started
6.10.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see ..)
FBSDKLog: Unable to find a valid UIWindow
Something!
[WindowScene] Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?
Unbalanced calls to begin/end appearance transitions for <ProjectName.Home: 0x7ffa2640ff90>.
Editing to clarify:
The point in attempting to try to programmatically set the initial VC is so that any VC can be set. This is useful in scenarios such as when the app initially loads, checking if the user is logged in or not, and depending on the token, showing the respective screen.
Trying to avoid having an intermediate VC that does the forwarding, because with iOS 13, the order of windows is layered.
Thank you everyone!