FirebaseUI-iOS icon indicating copy to clipboard operation
FirebaseUI-iOS copied to clipboard

Runtime error in call to authViewController(): 'Could not load NIB in bundle: 'NSBundle ... (loaded)' with name 'FIRAuthPickerViewController''

Open davidsantiago opened this issue 10 years ago • 34 comments

  • Objective C or Swift: Swift
  • iOS version: 9.3.5
  • Firebase SDK version: 3.4.0
  • FirebaseUI version: 0.5.4
  • CocoaPods Version: 1.1.0-rc1
  • Xcode version: 8.0 GM

Step 3: Describe the problem:

Sorry to be back here so soon after you were so quick on the turnaround with the other issue I posted earlier.

Now that 0.5.4 will build correctly, I get an exception about the bundle not being able to open the NIB file "FIRAuthPickerViewController" at runtime when FIRAuthUI.authViewController() is called.

Steps to reproduce:

  1. Code below fails at runtime. This happens in my own project, but I see that it also happens in the sample code in this repo, so I'll reference that. Start the uidemo project, select the Auth demo, hit Start, and it'll crash immediately.

Observed Results:

The code compiles and runs, but it throws an exception at runtime during the call to authUI!.authViewController().

Here is the barf at runtime:

2016-09-12 17:08:00.576 uidemo[6783:3230924] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/containers/Bundle/Application/5A387BD1-3913-41CB-A5E1-88A7306AC0E9/uidemo.app> (loaded)' with name 'FIRAuthPickerViewController'' *** First throw call stack: (0x18333adb0 0x18299ff80 0x18333acf8 0x1889733a4 0x188815230 0x1885da118 0x1885a8ea4 0x18849c8ec 0x18849c844 0x100093b40 0x1000967d4 0x10009bdc8 0x10002426c 0x10002455c 0x1884d4be8 0x1884d4b64 0x1884bc870 0x1884d4454 0x1884d4084 0x1884ccc20 0x18849d04c 0x18849b628 0x1832f109c 0x1832f0b30 0x1832ee830 0x183218c50 0x184b00088 0x188506088 0x100032430 0x182db68b8) libc++abi.dylib: terminating with uncaught exception of type NSException

Expected Results:

The function to successfully return the ViewController.

Relevant Code:

https://github.com/firebase/FirebaseUI-iOS/blob/070ad199730d467eacd96aeaec773082a1cc81d8/samples/swift/uidemo/AuthViewController.swift#L82

davidsantiago avatar Sep 13 '16 00:09 davidsantiago

same issue in demo. Um. I can't sure that it could be initWithNibName:bundle: method issues. To test it, I did change FIRAuthUIBaseViewController code a little bit using dev_pod, the auth demo has no issues. Does we need to change source code? Is it another issue about configuring frameworks?

// 'FIRAuthUIBaseViewController.h' 
- (instancetype)initWithNibName:(NSString *)nibNameOrNil
                         bundle:(NSBundle *)nibBundleOrNil
                         authUI:(FIRAuthUI *)authUI {
  NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"FIRAuthPickerViewController" ofType:@"nib"];
  NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];

  self = [super initWithNibName:bundlePath bundle:bundle];

dakeshi avatar Sep 13 '16 01:09 dakeshi

Hm, interesting. But it seems like the problem might actually be in the code that calls this base class function: https://github.com/firebase/FirebaseUI-iOS/blob/070ad199730d467eacd96aeaec773082a1cc81d8/FirebaseAuthUI/FIRAuthPickerViewController.m#L64

davidsantiago avatar Sep 13 '16 07:09 davidsantiago

Hi, I am having the same issue as davidsantiago.

Objective C or Swift: Objective C iOS version: 9.3.5 Firebase SDK version: 3.5.2 FirebaseUI version: 0.5.4 CocoaPods Version: 1.1.0-rc1

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle ... (loaded)' with name 'FIRAuthPickerViewController'' *** First throw call stack: (0x2330791b 0x22aa2e17 0x23307861 0x27d36761 0x27be9aa3 0x279bcffb 0x2798d177 0x27882a1f 0x27882971 0x1f58cd 0x1f7fe1 0x1fcb2f 0xa4f29 0x27882a1f 0x27882971 0x27889639 0x27886b3d 0x278fba5d 0x93045 0x278f7785 0x27b1f2d1 0x27b23285 0x27b3783d 0x27b207b3 0x249aac07 0x249aaab9 0x249aadb9 0x232c9dff 0x232c99ed 0x232c7d5b 0x23217229 0x23217015 0x278f0c3d 0x278eb189 0xf6d3d 0x22ebf873) libc++abi.dylib: terminating with uncaught exception of type NSException

wjuniorgit avatar Sep 13 '16 19:09 wjuniorgit

This is a podspec issue, fix coming soon 👍

morganchen12 avatar Sep 13 '16 22:09 morganchen12

This should be fixed in 0.5.5

morganchen12 avatar Sep 13 '16 23:09 morganchen12

This issue still seems to exist. I'm using 'FirebaseUI/Auth', '~> 1.0', any suggestions?

newPrimitives avatar Dec 02 '16 06:12 newPrimitives

@newPrimitives your issue is likely slightly different from this one. Can you post the stack trace here?

morganchen12 avatar Dec 02 '16 17:12 morganchen12

@morganchen12 It might be that I made a mistake in the migration, I inherited the code 3 days ago. Here is the stack trace:

2016-12-02 19:09:25.849 OneCoworking[24112:831553] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/nermin/Library/Developer/CoreSimulator/Devices/E5CCA957-2AC1-438F-9C52-4C95886B564E/data/Containers/Bundle/Application/4D4A6DDF-CCBA-4345-9140-E00956962D10/OneCoworking.app> (loaded)' with name 'One_Coworking.CustomFIRAuthPickerViewController''

*** First throw call stack:
(
	0   CoreFoundation                      0x000000010f4e334b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010edc621e objc_exception_throw + 48
	2   CoreFoundation                      0x000000010f54c265 +[NSException raise:format:] + 197
	3   UIKit                               0x000000010feedbd2 -[UINib instantiateWithOwner:options:] + 507
	4   UIKit                               0x000000010fc81c21 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
	5   UIKit                               0x000000010fc82543 -[UIViewController loadView] + 177
	6   UIKit                               0x000000010fc82878 -[UIViewController loadViewIfRequired] + 201
	7   UIKit                               0x000000010fc830cc -[UIViewController view] + 27
	8   OneCoworking                        0x000000010a9f7bda -[FUIAuthBaseViewController initWithNibName:bundle:authUI:] + 553
	9   OneCoworking                        0x000000010a9fb1b4 -[FUIAuthPickerViewController initWithNibName:bundle:authUI:] + 89
	10  OneCoworking                        0x000000010a955fe6 _TFC13One_Coworking33CustomFIRAuthPickerViewControllercfT7nibNameGSqSS_6bundleGSqCSo6Bundle_6authUICSo7FUIAuth_S0_ + 358
	11  OneCoworking                        0x000000010a9561bf _TToFC13One_Coworking33CustomFIRAuthPickerViewControllercfT7nibNameGSqSS_6bundleGSqCSo6Bundle_6authUICSo7FUIAuth_S0_ + 207
	12  OneCoworking                        0x000000010a9fb12d -[FUIAuthPickerViewController initWithAuthUI:] + 121
	13  OneCoworking                        0x000000010a894524 _TTOFCSo27FUIAuthPickerViewControllercfT6authUICSo7FUIAuth_S_ + 36
	14  OneCoworking                        0x000000010a89415c _TFCSo27FUIAuthPickerViewControllerCfT6authUICSo7FUIAuth_S_ + 76
	15  OneCoworking                        0x000000010a8940e7 _TFC13One_Coworking23FirebaseLoginController24authPickerViewControllerfT9forAuthUICSo7FUIAuth_CSo27FUIAuthPickerViewController + 55
	16  OneCoworking                        0x000000010a8941aa _TToFC13One_Coworking23FirebaseLoginController24authPickerViewControllerfT9forAuthUICSo7FUIAuth_CSo27FUIAuthPickerViewController + 58
	17  OneCoworking                        0x000000010aa011f6 -[FUIAuth authViewController] + 267
	18  OneCoworking                        0x000000010a893e4d _TFC13One_Coworking23FirebaseLoginController26createSignInViewControllerfT_GSqCSo16UIViewController_ + 525
	19  OneCoworking                        0x000000010a91358b _TFC13One_Coworking18AuthFlowController17connectToFirebasefT_T_ + 59
	20  OneCoworking                        0x000000010a9113d6 _TFC13One_Coworking18AuthFlowController3actfT_T_ + 230
	21  OneCoworking                        0x000000010a910b15 _TFFC13One_Coworking18AuthFlowControllercFT18rootViewControllerCSo16UIViewController_S0_U_FTCSo7FIRAuthGSqCSo7FIRUser__T_ + 133
	22  OneCoworking                        0x000000010a8929d3 _TTRXFo_oCSo7FIRAuthoGSqCSo7FIRUser___XFo_iTS_GSqS0____iT__ + 35
	23  OneCoworking                        0x000000010a910ea1 _TPA__TTRXFo_oCSo7FIRAuthoGSqCSo7FIRUser___XFo_iTS_GSqS0____iT__ + 81
	24  OneCoworking                        0x000000010a892597 _TTRXFo_iTCSo7FIRAuthGSqCSo7FIRUser___iT__XFo_oS_oGSqS0____ + 39
	25  OneCoworking                        0x000000010a892681 _TTRXFo_oCSo7FIRAuthoGSqCSo7FIRUser___XFdCb_dS_dGSqS0____ + 81
	26  OneCoworking                        0x000000010a9e4059 __41-[FIRAuth addAuthStateDidChangeListener:]_block_invoke.275 + 58
	27  libdispatch.dylib                   0x0000000111ff2980 _dispatch_call_block_and_release + 12
	28  libdispatch.dylib                   0x000000011201c0cd _dispatch_client_callout + 8
	29  libdispatch.dylib                   0x0000000111ffc8d6 _dispatch_main_queue_callback_4CF + 406
	30  CoreFoundation                      0x000000010f4a74f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	31  CoreFoundation                      0x000000010f46cf8d __CFRunLoopRun + 2205
	32  CoreFoundation                      0x000000010f46c494 CFRunLoopRunSpecific + 420
	33  GraphicsServices                    0x0000000113d95a6f GSEventRunModal + 161
	34  UIKit                               0x000000010fae1964 UIApplicationMain + 159
	35  OneCoworking                        0x000000010a92d28f main + 111
	36  libdyld.dylib                       0x000000011206868d start + 1
	37  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Objective C or Swift: Swift iOS version: 9.3.5 Firebase SDK version: 3.10.0 FirebaseUI version: 1.0.0 CocoaPods Version: 1.1.1

This is the code implementation which causes the app to crash:

authUI!.providers = authConfiguration.signInProviders
return authUI!.authViewController()

Array of providers only has Facebook.

newPrimitives avatar Dec 02 '16 18:12 newPrimitives

It looks like you've overwritten the default controller to expect a different nib which isn't provided by Firebase.

... with name 'One_Coworking.CustomFIRAuthPickerViewController'

morganchen12 avatar Dec 02 '16 19:12 morganchen12

I just noticed, makes sense. Thank you for pointing this out. I just don't understand how the application worked on Swift 2? Where there some drastic changes in the library?

newPrimitives avatar Dec 02 '16 20:12 newPrimitives

Yeah, we've made a great deal of changes since then. This could be better documented IMO.

morganchen12 avatar Dec 02 '16 22:12 morganchen12

I'm running into the same issue as @newPrimitives -- Is there some code we need to add to our FUIAuthPickerViewController subclasses in order to point to the correct NIB file?

My subclass only consists of an overridden viewDidLoad with a call to super.viewDidLoad(). All full explanation (with code) of my problem can be found here.

cohenadair avatar Dec 21 '16 00:12 cohenadair

After pod update, I ran into this issue again.

As a workaround I've override

 - (instancetype)initWithNibName:(NSString *)nibNameOrNil
                         bundle:(NSBundle *)nibBundleOrNil
                         authUI:(FUIAuth *)authUI; 

from Super "FUIAuthPickerViewController" into my own "CustomAuthPickerViewController" and hardcoded the @"FUIAuthPickerViewController" NibName.

@implementation CustomAuthPickerViewController
...

 - (instancetype)initWithNibName:(NSString *)nibNameOrNil
                         bundle:(NSBundle *)nibBundleOrNil
                         authUI:(FUIAuth *)authUI {

     self = [super initWithNibName:@"FUIAuthPickerViewController"
                           bundle:nibBundleOrNil
                           authUI:authUI];

    if (self) {
        self.title = @"Your Title";
     }

    return self;
} 

...
@end

wjuniorgit avatar Dec 21 '16 13:12 wjuniorgit

Ah, so it appears to be a bug, then.

The default implementation, uses NSStringFromClass([self class]), which I guess returns the subclass name rather than the superclass name.

I am unable to tell from the history if this was a recent change, however.

@wjuniorgit Thanks for the tip. I thought I tried that, but I don't think I was quite doing it right. I'm new to Swift and still getting used to the different syntax, but I'll try it again ASAP.

cohenadair avatar Dec 21 '16 13:12 cohenadair

Ah, yeah, we should fix that.

morganchen12 avatar Dec 21 '16 17:12 morganchen12

For anyone interested, a temporary solution for Swift:

import UIKit
import FirebaseAuthUI

class AuthViewController: FUIAuthPickerViewController {
    
    override init(nibName: String?, bundle: Bundle?, authUI: FUIAuth) {
        super.init(nibName: "FUIAuthPickerViewController", bundle: bundle, authUI: authUI)
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
}

cohenadair avatar Dec 22 '16 01:12 cohenadair

Why not to use next method?

- (FUIAuthPickerViewController *)authPickerViewControllerForAuthUI:(FUIAuth *)authUI {
  return [[FUICustomAuthPickerViewController alloc]
             initWithNibName:NSStringFromClass([FUIAuthPickerViewController class])
                      bundle:[NSBundle bundleForClass:[FUIAuthPickerViewController class]]
                      authUI:authUI];
}

yramanchuk avatar Jan 05 '17 01:01 yramanchuk

I tried using a custom picker again after a while and I see that on selecting "Sign in with email" the navigation bar buttons (Cancel, Next) are still missing from the next screen. I mainly wanted to use a custom picker in order to use my own background image and remove the "Welcome" label on the main login screen only. Is there an easy way to do just these and leave the other functionality intact?

yorgosg avatar Jan 08 '17 03:01 yorgosg

@yorgosg The "Sign in with email" screen is showing both the "Back" and "Next" buttons for me after subclassing FUIAuthPickerViewController using the code above.

In your version, is the navigation bar still showing (and the buttons are just missing)?

cohenadair avatar Jan 08 '17 14:01 cohenadair

@cohenadair thanks a million. It turns out I was removing the navigation bar, because I think I had to on the previous implementation of FirebaseUI. It now all works. Only one more thing: Is there a way to get rid of the "Welcome" label? I found a FirebaseAuthUI.strings file, where you can change "Welcome" to something else, but I don't know how to change its color or remove it altogether.

Thank you!!

yorgosg avatar Jan 08 '17 14:01 yorgosg