Black Screen only in IOS 13 when i run my application in testflight

I am stuck with my application, its work in a developer device and emulator too with IOS 13, but when i generate and upload the release version in the testflight, the application in the same device start the launchscreen and quickly show a black screen. I use and older iphone with IOS 12.4.2 and the same build works fine. I need help. This is the link of my testflight https://testflight.apple.com/join/maFeskwL


This is my app AppDelegate code:

import UIKit
import CoreData
import CoreLocation
import GoogleMaps
import OneSignal
import GoogleMobileAds
import PianoOAuth
import SDWebImage
import Firebase

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate, ESTBeaconManagerDelegate { //, ESTBeaconManagerDelegate {

    var window: UIWindow?
    var beaconManager = ESTBeaconManager.init()
    var locationManager: CLLocationManager = CLLocationManager()
    var listUUIDs : [String] = []
    var monitoreando = 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) {
        // 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.
    }
  
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:
        [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        MyDBhelper.init().CargarDatos()
        if (RepositorioCategoria().obtenerCategorias(origen: "LA PRENSA").count == 0) {
            if(Utilidades().isConnectedToNetwork()) {
                RepositorioCategoria().consumirWS(origen: "LA PRENSA") { (response) in
                    DispatchQueue.main.async {
                        self.iniciar()
                    }
                }
            } else {
                self.iniciar()
            }
        } else {
            self.iniciar()
        }

        UIApplication.shared.registerUserNotificationSettings(
            UIUserNotificationSettings(types: .alert, categories: nil))

        GADMobileAds.sharedInstance().start(completionHandler: nil)
  
        FirebaseApp.configure()
              
        GMSServices.provideAPIKey("******")
      
        let onesignalInitSettings = [kOSSettingsKeyAutoPrompt: false]
      
        let notificationOpenedBlock: OSHandleNotificationActionBlock = { result in
            // This block gets called when the user reacts to a notification received
            //let payload: OSNotificationPayload? = result?.notification.payload
          
            if let additionalData = result!.notification.payload!.additionalData {
                let variableNoticia = RepositorioParametrizacion().obtenerParametrizacionById(IdParametrizacion: "VariableNoticia")
                if variableNoticia.Id_Parametrizacion == "" {
                    if (additionalData["id_noticia"] != nil) {
                        let parametro = Parametrizacion.init(Id_Parametrizacion: "VariableNoticia", Valor: (additionalData["id_noticia"] as! String), Fecha_Valor: -4)
                        RepositorioParametrizacion().insertar(parametrizacion: parametro)
                    }
                } else {
                    if (additionalData["id_noticia"] != nil) {
                        variableNoticia.Valor = additionalData["id_noticia"] as! String
                        variableNoticia.Fecha_Valor = -4
                        RepositorioParametrizacion().actualizar(IdParametrizacion: "VariableNoticia", parametrizacion: variableNoticia)
                    }
                }
                self.iniciar()
            }
        }
      
        OneSignal.initWithLaunchOptions(launchOptions,
                                        appId: "*********",
                                        handleNotificationAction: notificationOpenedBlock,
                                        settings: onesignalInitSettings)
      
        OneSignal.inFocusDisplayType = OSNotificationDisplayType.notification;
      
        let currentUser = RepositorioUsuario().obtenerUsuario()
        if currentUser.Email != "" {
            OneSignal.sendTag("email", value: currentUser.Email)
            if currentUser.Suscriptor != "" {
                OneSignal.sendTag("esSuscritor", value: "1")
            } else {
                OneSignal.sendTag("esSuscritor", value: "0")
            }
        }
      
      
        // Recommend moving the below line to prompt for push after informing the user about
        //   how your app will use them.
        OneSignal.promptForPushNotifications(userResponse: { accepted in
            print("User accepted notifications: \(accepted)")
        })
      
        return true
    }
 
    func userNotificationCenter(_ center: UNUserNotificationCenter,
              willPresent notification: UNNotification,
              withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        if Int(notification.request.content.userInfo["idNotificacion"] as! String)! > 0 {
            let resultado = notification.request.content.userInfo["idNotificacion"] as! String
            print(resultado)
          
            if resultado.count > 0 {
                let sb: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
                let navigationView = sb.instantiateViewController(withIdentifier: "UrlBeaconNavigationController") as! UrlBeaconNavigationController
                let frontVC = navigationView.topViewController as! UrlBeaconViewController
                frontVC.idNotificacion = Int64(resultado)!
                frontVC.fechaNotificacion = Date()
                frontVC.tipoNotificacion = 2
                self.window?.rootViewController = navigationView
                self.window?.makeKeyAndVisible()
            }
        }
    }
  
    
  
    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        //FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
        return true
    }
  
  
  
//    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
//        return Twitter.sharedInstance().application(app, open: url, options: options)
//    }
  
    func iniciar() {
      
        if #available(iOS 13.0, *) {
            // In iOS 13 setup is done in SceneDelegate
        } else {
            let storyboard = UIStoryboard(name: "Main", bundle: nil)
            var vc = storyboard.instantiateViewController(withIdentifier: "inicio") as! SWRevealViewController
            self.window?.rootViewController = vc
            self.window?.makeKeyAndVisible()
            vc.removeFromParent()
        }
      
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
        //FBSDKAppEvents.activateApp()
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
        //AppEventsLogger.activate(application)
    }
  
    func applicationDidReceiveMemoryWarning(_ application: UIApplication) {
        SDImageCache.shared.clearMemory()
        SDImageCache.shared.clearDisk()
        URLCache.shared.removeAllCachedResponses()
        // Delete any associated cookies
        if let cookies = HTTPCookieStorage.shared.cookies {
            for cookie in cookies {
                HTTPCookieStorage.shared.deleteCookie(cookie)
            }
        }
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
        // Saves changes in the application's managed object context before the application terminates.
        self.saveContext()
    }
  
    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        return PianoID.shared.handleUrl(url, options: options)
    }

    // MARK: - Core Data stack

    lazy var persistentContainer: NSPersistentContainer = {
        /*
         The persistent container for the application. This implementation
         creates and returns a container, having loaded the store for the
         application to it. This property is optional since there are legitimate
         error conditions that could cause the creation of the store to fail.
        */
        let container = NSPersistentContainer(name: "LaPrensa")
        container.loadPersistentStores(completionHandler: { (storeDescription, error) in
            if let error = error as NSError? {
                // Replace this implementation with code to handle the error appropriately.
                // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
               
                /*
                 Typical reasons for an error here include:
                 * The parent directory does not exist, cannot be created, or disallows writing.
                 * The persistent store is not accessible, due to permissions or data protection when the device is locked.
                 * The device is out of space.
                 * The store could not be migrated to the current model version.
                 Check the error message to determine what the actual problem was.
                 */
                fatalError("Unresolved error \(error), \(error.userInfo)")
            }
        })
        return container
    }()

    // MARK: - Core Data Saving support

    func saveContext () {
        let context = persistentContainer.viewContext
        if context.hasChanges {
            do {
                try context.save()
            } catch {
                // Replace this implementation with code to handle the error appropriately.
                // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
                let nserror = error as NSError
                fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
            }
        }
    }

}


and this is the SceneDelegate file


@available(iOS 13.0, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    var window: UIWindow?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = (scene as? UIWindowScene) else { return }

        let window = UIWindow(windowScene: windowScene)
        self.window = window

        let mainstoryboard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let newViewcontroller:UIViewController = mainstoryboard.instantiateViewController(withIdentifier: "inicio") as! SWRevealViewController
        window.rootViewController = newViewcontroller
        window.makeKeyAndVisible()
    }

    func sceneDidDisconnect(_ scene: UIScene) {
        // Called as the scene is being released by the system.
    }

    func sceneDidBecomeActive(_ scene: UIScene) {
        // Not called under iOS 12 - See AppDelegate applicationDidBecomeActive
    }

    func sceneWillResignActive(_ scene: UIScene) {
        // Not called under iOS 12 - See AppDelegate applicationWillResignActive
    }

    func sceneWillEnterForeground(_ scene: UIScene) {
        // Not called under iOS 12 - See AppDelegate applicationWillEnterForeground
    }

    func sceneDidEnterBackground(_ scene: UIScene) {
        // Not called under iOS 12 - See AppDelegate applicationDidEnterBackground
    }
}


This is my

Answered by djericck1989 in 390572022

I could resolve my problem, it was in the storyboard. only i remove the searchDisplayController references.


<searchDisplayController id="pWz-So-g6H">
<connections>
<outlet property="delegate" destination="Yci-sd-Mof" id="fjs-ah-jLs"/>
<outlet property="searchContentsController" destination="Yci-sd-Mof" id="gQN-1r-gti"/>
<outlet property="searchResultsDataSource" destination="Yci-sd-Mof" id="2Jf-lh-Ute"/>
<outlet property="searchResultsDelegate" destination="Yci-sd-Mof" id="Hap-SA-f02"/>
</connections>
</searchDisplayController>

Have you completed the info.plist for the sceneDelegate ?


You need to include:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>UIApplicationSupportsMultipleScenes</key>

<false/>

<key>UISceneConfigurations</key>

<dict>

<key>UIWindowSceneSessionRoleApplication</key>

<array>

<dict>

<key>UISceneConfigurationName</key>

<string>Default Configuration</string>

<key>UISceneDelegateClassName</key>

<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>

<key>UISceneStoryboardFile</key>

<string>Main</string>

</dict>

</array>

</dict>

</dict>

</plist>

Yes, but still not working when i try to build with target 13.1



key>UIApplicationSceneManifest</key>

<dict>

<key>UIApplicationSupportsMultipleScenes</key>

<false/>

<key>UISceneConfigurations</key>

<dict>

<key>UIWindowSceneSessionRoleApplication</key>

<array>

<dict>

<key>UILaunchStoryboardName</key>

<string>Main</string>

<key>UISceneConfigurationName</key>

<string>Default Configuration</string>

<key>UISceneDelegateClassName</key>

<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>

</dict>

</array>

</dict>

</dict>

Accepted Answer

I could resolve my problem, it was in the storyboard. only i remove the searchDisplayController references.


<searchDisplayController id="pWz-So-g6H">
<connections>
<outlet property="delegate" destination="Yci-sd-Mof" id="fjs-ah-jLs"/>
<outlet property="searchContentsController" destination="Yci-sd-Mof" id="gQN-1r-gti"/>
<outlet property="searchResultsDataSource" destination="Yci-sd-Mof" id="2Jf-lh-Ute"/>
<outlet property="searchResultsDelegate" destination="Yci-sd-Mof" id="Hap-SA-f02"/>
</connections>
</searchDisplayController>

I've got this exact issue I believe, currently attempting to confirm removing searchDisplayController form storyboard resolves it. I also do not have the UISceneDelegate key or any of the manifest suggestions mentioned above. Will be testing that as well if this fails.


Could you clarify what you did specifically to resolve this? I'm guessing you removed the SearchDisplayController from your storyboard entirely and instantiated it programmatically instead?


Any more info would be much appreciated as this has wasted a day of my time already with the slow release build testing process.


Thanks!

It seems Djerrick only removed the connections.

May look at them in Connections inspector ?

I resolved this successfully by removing all references to searchDisplayController from my story board. I'd actually stopped using it previously but there were some leftover storyboard references. Found more discussion of this here: https://github.com/mapbox/mapbox-gl-native/issues/15559


Thank you djericck1989this was a tricky one! How did you determine this was the cause?

Maybe someone have similar issue, i just wanted to share.
We have @ionic/react capacitor -app and normally i did not get any error, at testFlight we get black screen, 
check config.capacitor.json and see if u have localhost there, delete URLs under server ..
we(I) forgot our URL localhost still there, to be honest i did not know that could be problem ,
i spent time(days) to check storyBoard suggestions.

xcode 11.6
Hello. I solve this problem coding with "class let willDeactivateNotification: NSNotification.Name" for the screen background and coding "class let didActivateNotification: NSNotification.Name" for the screen foreground:

if #available(iOS 13.0, *) {
      NotificationCenter.default.addObserver(self, selector: #selector(setDarkScreenObj), name: UIScene.willDeactivateNotification, object: nil)
    }else {
      NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: nil) { (notification) in
        self.setDarkScreen()
      }
    }
     
    if #available(iOS 13.0, *) {
      NotificationCenter.default.addObserver(self, selector: #selector(setLightScreeenObj), name: UIScene.didActivateNotification , object: nil)
    }else {
      NotificationCenter.default.addObserver(forName:UIApplication.willEnterForegroundNotification, object: nil, queue: nil) {
        (notification) in
        self.setLightScreeen()
      }
    }



Reference: https://developer.apple.com/documentation/uikit/uiscene/3197922-didenterbackgroundnotification

Black Screen only in IOS 13 when i run my application in testflight
 
 
Q