My app supports older versions of iOS 10.0 and above. When I try to launch my app in iOS 13, it shows a black window. It does configure initial ViewController and shows labels when I remove the scene delegate. Everything works in iOS 12 and under with just App delegate.
In my App delegate:
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
configureInitialViewController()
return true
}
func configureInitialViewController()
{
var initialVC: UIViewController
let mainsb = UIStoryboard(name: "Main", bundle: nil)
if Auth.auth().currentUser != nil {
//print("successfully signed in")
initialVC = mainsb.instantiateViewController(withIdentifier: IDENTIFIER_MAIN_TABBAR)
} else {
//print("successfully signed out")
initialVC = mainsb.instantiateViewController(withIdentifier: IDENTIFIER_WELCOME_NAV)
}
window?.rootViewController = initialVC
window?.makeKeyAndVisible()
}
func applicationWillResignActive(_ application: UIApplication) {
Api.User.isOnline(bool: false)
}
// MARK: UISceneSession Lifecycle
@available(iOS 13.0, *)
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
@available(iOS 13.0, *)
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
In my Scene delegate:
@available(iOS 13.0, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
}
func sceneWillResignActive(_ scene: UIScene) {
Api.User.isOnline(bool: false)
}
}
I also deleted Application Scene Manifest in my info.plist.
Can someone help me check if I'm setting up version supports correctly?
I would really appreciate any help.
Update:
I tested it works in iOS 13.5 but not 13.2 or 14.3. Why is it showing different behaviors in different versions?
question from:
https://stackoverflow.com/questions/66057808/black-screen-on-launch-how-to-support-all-versions-ios-10-and-13-above-in-app-a 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…