iOS Framework - Loaded the nib but the view outlet was not set

1.1k views Asked by At

I saw many questions similar to mine but no solutions worked and this may be because I am creating and then importing an iOS framework into a project.

Basically, I have a SignIn framework and I want to show a webview if the user is not signed in.

My normal project will call my framework and if I need to authenticate, the SignIn framework will tell me to load a certain .xib to sign in.

In my framework, this .xib is named SignIn.xib It contains a view controller with a webview inside as you an see:

enter image description here

Now, in my framework, I init the view controller and call a function of the delegate to load the signInView:

NSString* const frameworkBundleID  = @"iOSLoginSDK";
NSBundle* bundle = [NSBundle bundleWithIdentifier:frameworkBundleID];

SignInViewController* signInViewController = [[SignInViewController alloc] initWithNibName:@"SignIn" bundle:bundle];

[self.delegate loadSignInView:signInViewController];

In my project, I simply do the following and this method will be called by the delagate:

-(void) loadSignInView:(CYMSignInViewController *)signInViewController {
     [self presentViewController:signInViewController animated:YES completion:nil];
}

However, I have the following error when I try to run the application:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "SignIn" nib but the view outlet was not set.

I am using XCode 6.3.2

Edit 1: I think the problem happens because I have a view controller inside my xib. Can I do that?

Edit 2: Here are my outlets in my .xib

enter image description here

Edit3: I tried to recreate the nib but I still get the same error.

Here are the steps I did:

  1. I created an empty xib
  2. I added a view controller and then I added my element onto it
  3. I created a view controller file and I set it as the custom class of the view controller

Am I missing something here?

1

There are 1 answers

1
Etienne Noël On BEST ANSWER

Okay, so basically, it seems like you can't have a view controller in a standalone .xib. I think because the .xib is a view controller in a way (someone could clarify).

What I did, is that I created a view, set my design properly and then, I assigned my ViewController class file to the File's owner. That way, it is now working.