Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crash Xcode 11, iOS13 setting root view controller

Since a few days I've been experiencing a very strange crash when debugging our app within Xcode 11.

Situation

We have an app built for iOS 11 and higher. But since Xcode 11 the app is crashing on setting the root view controller. But when I open the app after it crashed, the app does work so it seems it has something to do with setup a debug session.

The device where I try to build on is an iPhone Xs, with iOS 13.1.2. I also tried another device with 13.1 but having the same issue there.

However, when I attach a device that is running on 12.x.x it's working.

Strangely, yesterday I was able to run on a simulator. But since today the same crash occures on a device (iPhone Xs).

Also maybe important to mention: colleagues of me that work with the same project, do not have the same issues. (!!)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Show app loading view controller
self.window = [[RMWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [[AppLoadingViewController alloc] init]; // Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
[self.window makeKeyAndVisible];

I tried the following:

  • Replaced AppDelegate.h/m by AppDelegate.swift.
  • Update all project settings to latest settings from Xcode 11.
  • Tried a plain UIViewController() instead of AppLoadingViewController().
  • Cleaned Derived Folder (hardcore style)
  • Clean all Xcode cache
  • Reinstall Xcode
  • Restarted Mac + iPhone
  • Removed the iOS DeviceSupport folder from Xcode preferences, re-connected device via 'Devices and Simulators'.
  • Created a new project and run on iPhone, DOES work.

This is an app that contains both Objective-C and Swift code, we have it already for years. But it's the first time that something like this is happening.

Is there anyone who has an idea of what this could be?

like image 383
NielsKoole Avatar asked Oct 03 '19 11:10

NielsKoole


People also ask

How do I set root view controller programmatically?

plist file → Application Scene Manifest property → Scene Configuration → item 0 and get rid of the property Storyboard Name by clicking the icon that has a minus in the circle next to it. ► Run the app and you will see the black screen and let's change that by setting a new root view controller.

How do I get to the root view controller in Swift?

The root view controller is simply the view controller that sits at the bottom of the navigation stack. You can access the navigation controller's array of view controllers through its viewControllers property. To access the root view controller, we ask for the first item of the array of view controllers.


1 Answers

    let homeVC = UIStoryboard(name:"Main", bundle: nil).instantiateViewController(withIdentifier: "SigninViewController") as! SigninViewController
    let navC = UINavigationController(rootViewController: homeVC)
    navC.navigationBar.isHidden = true
    UIApplication.shared.windows.first?.rootViewController = navC
    UIApplication.shared.windows.first?.makeKeyAndVisible()

try this it is working Fine in my case..

like image 169
Shubham Choudhary Avatar answered Oct 07 '22 09:10

Shubham Choudhary