Failed to Instantiate the Default View Controller for Uimainstoryboardfile 'Main' - Perhaps the Designated Entry Point Is Not Set

Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?

So this also happened to me too. I checked 50 times and my "Is Initial View Controller" was checked, believe me. It happened out of the blue. So how did I fix it?

  1. Create a new Storyboard in your project, name it something like Main_iPhoneV2 (or iPadV2 depending on your original storyboard style)
  2. Open the broken storyboard, click anywhere in the white area and press command-a, then command-c (select all and copy)
  3. Open your new storyboard and press command-v to paste the same exact setup
  4. Go to your project settings, change your "Main Interface" to the new Main_iPhoneV2 (If it's your iPad and you're writing a universal app, you'll have to edit the -Info.plist and look for the value "Main storyboard file base name (iPad)
  5. Recompile, and stop pulling your hair out

Failed to instantiate the default view controller for UIMainStoryboardFile

Failed to instantiate the default view controller for
UIMainStoryboardFile 'Main' - perhaps the designated entry point is
not set?

This error happens due to a simple mistake in your storyboard. When your app starts, iOS needs to know precisely which view controller needs to be shown first – known as your default view controller.

To fix it, add a ViewController to your Main.Storyboard and set it as Inital View Controller.

Sample Image

Refer: how-to-fix-the-error-failed-to-instantiate-the-default-view-controller-for-uimainstoryboardfile

And there are two SignInViewController in your project.

Use this one:

public partial class SignInViewController : UIViewController
{
public SignInViewController (IntPtr handle) : base (handle)
{
}

public override void ViewDidLoad()
{
// never gets called...

base.ViewDidLoad();

View.BackgroundColor = UIColor.Red;
}
}

Update:

Sample Image

Failed to instantiate the default view controller for UIMainStoryboardFile 'Main'

Select the ViewController Scene. Now, select the inspector panel from the sidebar options. Check the “Is Initial View Controller” attribute option, save the project and build the project again.

Programmatically set the initial view controller using Storyboards in Xcode 11.2

iOS 13 has moved the windows setup from AppDelegate to SceneDelegate to support the use of (possibly multiple) scenes rather than a single window. You now have to do the setup like this:

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?
let storyboard = UIStoryboard(name: "Main", bundle: nil)

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = scene as? UIWindowScene else { return }
let vc = storyboard.instantiateViewController (withIdentifier: "Primary") as! ViewController
window = UIWindow(windowScene: windowScene)
window?.rootViewController = vc
window?.makeKeyAndVisible()
}


Related Topics



Leave a reply



Submit