Search code examples
xamarinxamarin.iosmvvmcross

Failed to instantiate the default view controller for UIMainStoryboardFile


I am writing a small sample app with Xamarin and MvvmCross 6.4.2. I completed the Xamarin.Android version and am now starting the Xamarin.iOS version. I created a view controller for the first screen:

public class SignInViewController : MvxViewController<SignInViewModel>
{
    public SignInViewController() : base(nameof(SignInViewController), null)
    {
        
    }

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

        base.ViewDidLoad();
    }
}

When I run the app, I just get a blank screen and ViewDidLoad never gets called. In the application output it says:

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

My Main.storyboard is blank and I tried to modify it in Xcode Interface Builder to set my SignInViewController as the entry point, but I couldn't figure out how.


Solution

  • 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.

    enter image description here

    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:

    enter image description here