简体   繁体   中英

“Could not load NIB in bundle” error on iPhone but not on Simulator

Up until yesterday I had a perfectly working app on my iPhone. I made a few tweaks yesterday and now the app works on my simulator but not on the iPhone. The error message I am getting is right after the "applicationDidFinishLaunching" finishes.

The error is: 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle ....> (loaded)' with name 'RootViewController''"

The weird thing is, I don't have any xib files called RootViewController. I renamed mine a month ago to CategoryViewController and this has worked fine up until yesterday. I verified in each of my viewControllers that there is no reference to a "RootViewController".

I searched with "CTRL+shift+F" "RootViewController" and there is no file in my project that mentions this.

The tweaking I was doing had to do with the target info.plist and I only added the Application supports iTunes file sharing option. Here is my info.plist in case I messed something up:

info.plist

I also had run "Clean" for the first time yesterday.

I verified that my MainWindow.xib file has all the connections it is supposed to have and compared this against the original sample project I used as a base.

I tried reverting the project back to an earlier snapshot when I am positive it worked and now that doesn't even work. It seems my iPhone bundle got corrupt. But it does the same thing even after I delete the app from my iPhone and try again.

How do I go about debugging this? I have spent 10 hours already trying to fix this and really need some help.

The Xcode templates create an Info.plist file that specifies the main nib file.

-The default nib name is "MainWindow".
-The default version of that nib file contains a Navigation controller that references a view named "RootViewController".

However, each of those can have variations for iPhone or iPad. Those files have ~iphone or ~ipad added to the end. They system will pick the variation automatically by suffix.

You could have gotten a different nib file for that reason which tried to load RootViewController.

Also, if you have a view or view controller inside your nib that references RootViewController, the OS will try to load it. (It instantiates almost everything in a nib file once it is opened.)

This was resolved by refactoring and renaming my first viewController back to RootViewController. The moral of the story is do not change the name of the RootViewController. There are built in references to it that are not easily changed. There is no real need to use a different name. Once I did this, everything worked again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM