Addison F.
Addison F.

Reputation: 33

Xcode 11 Could not find a storyboard named 'Main' in bundle NSBundle

This question has been asked before, but my issue is specifically with Xcode 11 and UISceneConfiguration. Before Xcode 11, when you deleted a storyboard (Main.storyboard) from your target, then added a new one (AnotherStoryboard.storyboard), you would have to update Targets > General > Deployment Info > Main Interface to use your newly added storyboard. In Xcode 11, this is not sufficient and the app will throw an exception

*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Could not find a storyboard named 'Main' in bundle NSBundle

The problem I found was that in Info.plist, there is now a new key titled UIApplicationSceneManifest that has a nested UISceneStoryboardFile in it that is being updated when you change the Main Interface within the target. However, there is still a UIMainStoryboardFile key at the top level of Info.plist that is holding the title of the old "Main" storyboard. Long story short, if you delete UIMainStoryboardFile, the app will run fine.

My question: Is this a bug in Xcode 11 or is there something else I'm missing that would prevent this? I didn't really find anything useful while I was trying to debug it and ended up figuring it out on my own.

Upvotes: 3

Views: 10657

Answers (2)

rox79
rox79

Reputation: 21

In your info.plist you have to set this property Application Scene Manifest -> Scene Configuration -> Application Session Role -> Item 0 -> Storyboard Name

Info.plist

Upvotes: 1

Farhan Amjad
Farhan Amjad

Reputation: 774

In your info.plist Main file is set in Scene Configuration, So it always find that file and throw an exception. You can set your default ViewController programatically. In your info.plist set Scene Configuration to Default configuration and Select none into Targets > General > Deployment Info > Main Interface.

Your sceneWillConnectTo be like

  window = UIWindow(frame: UIScreen.main.bounds)
  window!.windowScene = windowScene
  window!.rootViewController = //your homeVC
  window!.makeKeyAndVisible()

Upvotes: 7

Related Questions