I'm trying to test an app I'm developing on my iPhone. To do that I changed the target from Simulator to Device on Xcode. The application is correctly uploaded to the device and it works. The main view is shown but if I try to open a secondary view, the application crashes.
On the iPhone log (I installed the iPhone configuration utility to see the console [is the only way to see the log from iPhone?]) I can see this error:
Could not load NIB in bundle
But, on the simulator it works fine. What's wrong? Any ideas?
I had the same problem and fixed it like so:
Open XCode Target
Click the "Build phases" tab
Click the "Copy bundle resources" section
Click the +
Add the missing Nib file
I've found that sometimes the device is case sensitive and the simulator is not.
What's the filename of your xib?
or
Try uninstalling the app from the simulator and installing it again - the simulator might have an old file left over from a previous run of the app - have you renamed / moved the xib at all during development?
I had a similar problem and was getting the same error. Turns out I was using the full name of the xib file in the attributes panel under "NIB Name:"
Don't use "SomeViewController.xib", just use "SomeViewController" without the ".xib" extension.
I had the same problem when invoking initWithNibName:#"MyViewController"
Changing the invocation to initWithNibName:NSStringFromClass([MyViewController class]) worked well
You can try these things:
Make sure case is correct
Use xib filename without the ".xib" extension
Remove any -(dash) or other special chars, use _(underscore)
Remove the xib file from the project and add back to the Xcode project
Check the build settings and make sure deployment is changed to currect SDK
In my case, the xib simply wasn't being copied into the bundle. Once I added the xib into the "Copy Bundle Resources" step for the application target, everything went fine.
I finally managed to solve that issue with these two steps:
In the view controller files inspector, remove any localization
(just for testing)
Ensure that you have checked the correct target membership
I don't know why it works on the simulator :(
For me, the problem was exactly what FreeAsInBeer said: the nib somehow was missing from the bundle, whereas it had been there before and worked properly in previous versions of the app.
To fix the problem, I did the following:
Select the project in the Project Navigator.
In the project settings select Build Phases.
Expand Copy Bundle Resources.
Scroll down (if necessary) and click on the + button.
In the dialog that appears, click on the Add Other... button.
Browse for the missing .XIB file in the file system.
Build and Run... the missing nib should appear when you run it.
This is just what worked for me when I got that message. Your mileage may vary, since circumstances are not always the same for everyone, but I hope this helps someone who runs into this issue.
-Evan
I ran into the same problem. In my case the nib name was "MyViewController.xib" and I renamed it to "MyView.xib". This got rid of the error.
I was also moving a project from XCode 3 to 4.2. Changing the Path type did not matter.
I had the same error message.
My problem, however was that my language settings on my phone were set on "English" and the Region on "United Kingdom". However, the file that could not be loaded was placed in the de.lproj directory.
Moving the file into the root directory solved it.
A simple mistake that might cause this error is trying to initWithNibName on an imported viewController when you are using a storyboard rather than individual Nib files. If this is the case then just init the controller instead of trying to init with a nib that doesn't exist, or init those fields with nil.
If Storyboard and no nib, change initWithNibName: bundle: to just be init OR initWithNibName:nil bundle:nil
For what its worth, I received this error when one of my tab bar buttons had the wrong class assigned to it.
I've got it to run with delete all of the localization from the xib
In the right window.
Maybe the file is in the localization folder.
I've the same problem. And my solution is remove all Localizations for the view.
I had exactly the behavior you described: works on simulator but get the "Could not load NIB in bundle" when running on the device, and the app remain stuck on the launch image.
In my case the problem was about the MainWindow.xib file that Xcode automatically created with English localization. I am supporting English and Italian in my app and realized that I was missing the localized version of MainWindow.xib for the Italian language.
Because I had no need to localize this file (it's Xcode default to create it localized) I fixed the problem by simply removing the English localization, so the same file is used independently of the localization. Another way to fix the problem would be to add the missing localized version, if you need it.
The app was crashing on the device because my device is configured for Italian language. The simulator instead was set to English and this is why the app run correctly. Just to verify, I set the simulator to Italian language and the app crashed confirming the localization problem.
I also had this problem when I loaded a child view controller from initWithCoder, which is a good place to initialise, but keep in mind you have to add it as an actual child AFTER the view has loaded.
So shift something like this:
[self addChildViewController: self.pageViewController];
[self.view addSubview: self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
...out of your init method and into viewDidLoad. Not saying this is your problem in particular but this may be helpful to others.
Related
I cannot run my project in simulator because i get this error:
Could not find a storyboard named 'MainStoryboard_iPad'
But the storyboard is there.
Thank you
I managed to solve this problem in my iPad App through the following steps:
Checking the Build Phases
Editing the Info.plist file to add the option "Main storyboard file base name (iPad)"
Just like in this picture:
In my case, the iPad storyboard file was already in the project, and testing the app worked until I introduced what seems to be an unrelated bug... I fixed this by changing the filename in xCode for the MainStoryBoard_iPad to MainStoryBoard_iPad1 and changing the TARGETS > Summary > iPad deployment Info > Main Storyboard entry. For good measure also verifying the same in -Info.plist file and Build Phases accordingly... similar to #daniel-lima.
Hopefully, this may help others that did not fix based on above notes. This started after I fixed a CoreData related bug in a category-file. The issue was reproducible on another machine... and this fixed it on both machines.
My issue was only on iOS 5. The resolution was found at http://need-bee.com/b/2013/08/could-not-find-a-storyboard-in-xcode-5-for-ios-5-0/
To summarize:
In Xcode, open each story board file and uncheck "Base" under localization on the right hand side. It will prompt you to move to English. Select ok. Once rebuilt my issue was resolved.
Click target and there is Mainstoryboard with textfield. Click and select your storyboard named "Mainstoryboard_iPad" and clean your project and then run it.
Remove from the project all the StoryBoards and add all of them again, for me worked.
I got this problem today as well, for me, a Product > Clean solved the problem. After that, I can rebuild the app and run it inside the Simulator without any issue.
I was encountering the same problem as in the original question but for me there wasn't really a bug - rather, the storyboard which appeared in the project navigator as "Main.Storyboard" actually had a base name of "Main" in info.plist. So my attempts to use "MainStoryboard" and "Main.Storyboard" in my code were generating a crash, but once I changed it to "Main" it worked just fine - didn't need any of the elaborate workarounds above.
If the failure occurs after launch, check to make sure any references to a storyboard via storyboardWithName: refers to the correct name. You may have an incorrect name hardcoded in your binary.
In my case, I renamed the storyboard (based on a suggested workaround on stack overflow), but forgot to rename references to the storyboard in code. The symptoms were that changes to the storyboard weren't visible in the running application, but once I reset the simulator, the app stopped working completely. In that case, the old, stale copy of the storyboard was around at first and was used; once the simulator was reset, the stale copy disappeared and the "could not find a storyboard" message started appearing.
When I run my app in the simulator it does load the xib file and all looks perfectly fine. As soon as I run in on my iphone4 I get a white page with "My Universal App on iPhone" but not my xib file.
how comes?
Try this: Clean all targets, delete Build folder and uninstall app from device.
It happened to me once too. Try to clean your project (cmd+maj+K).
Try to use the function InitWithNibName:#"YourNibName" without misspelling in YourNiBName.
Good luck
Check that the .xib file is still part of your project and set as a resource to copy at build time. This sort of thing tends to happen if you've removed a file from the build resources but there's still an old copy in the simulator's build directory.
Guys, i wonder if any one can help - My project was fully working in both the simulator and on a device, however, i renamed the project in xcode 4 (double clicking at the root of the project navigation pane, it was happy to rename any references - but now when i launch the app it only opens to the main window (yes it has outlets, all have outlets etc etc),
no code in the app delegate stops at a break point (even in didFinishLaunchingWithOptions)
so unsure what i could have missed, i have looked at other answers and everyone writes and says "missing outlet" etc.
I have dragged some backed up version of the app delegate that used to work and no difference, what could i be missing.
I do have source control, however currently in the process of merging from VSS to GIT.
thanks
lee
Check your Info.plist for what it uses as it's Main Nib File. Perhaps something changed there? Also, within the nib file itself you might have problematic connections to classes that are still named with the old name.
I have an iPhone xib I want to turn into an iPad xib. In Xcode 3 there was a "Create iPad Version" menu option. How do I do this in Xcode 4?
I currently resized my xib, but when I turn on the simulated items (Navigation Bar, etc.) it shrinks the view back down to iPhone size.
This worked for me:
Make a copy of the .xib in the Finder.
Open the copied file in a text editor.
Change "com.apple.InterfaceBuilder3.CocoaTouch.XIB" to "com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB".
Change all instances of "IBCocoaTouchFramework" to "IBIPadFramework".
Search for sizes like {480, 320} and edit them. Or just reopen the file in Xcode and use the GUI to resize items as needed.
This also works in reverse, if you need to change an iPad xib into an iPhone xib.
in Xcode 4 it's quite hidden, but the option to convert XIBS in the app still exists.
Select the target (in XCODE4 it's shown when you select the project). Once selected use the contextual menu to "Duplicate" it. It will ask if you want to "Duplicate and transition to iPad". Then all the XIBS will be duplicated with the new iPad size.
On assessing my options, these were my thoughts:
Too much of a hassle to install xcode 3 and downgrade project
Don't want to mess with .xib file format - afraid it might break something that will show itself much later
Copying the same nib is imperfect (see the explanations in this thread)
So finally, what I ended up doing that works fine is:
Create a new file, choose "UIViewController derived" class
Check the "intended for iPad" checkbox
Name the file -iPad
Delete the .h and .m corresponding to the uiviewcontroller
Now populate the new nib with the same objects, structure and connections as the original nib
Check if on iPad, if so then load the new nib else load the old nib
The feature has been removed from Xcode 4.
Right now the easiest way is to use Xcode 3 for the conversion, since the nib (.xib) file format did not change.
Xcode 3 & 4 can now be both installed on the same system by simply selecting a different folder (see installation instructions on the disk image).
Another simple way in XCode4 is: Just copy the iPhone XIB in Finder; drag the copy in your project. Open the copied XIB in XCodes build in interface builder. Change the size of the top view in your NIBs hirarchy to iPads dimensions (e.g. 1024x748 for landscape with statusbar) - everything else resizes according to the autoresizing masks.
Works perfect for me.
If you make a new nib, it will ask you if it should be sized for iPad. That might be the easiest unless you've already done a bunch of work on it.
You will have to use the older version of Interface Builder to use the "Create iPad version using autoresizing masks". There currently is no option in Xcode 4 that will do this.
Using XCode 4, all you have to do is select the (iPhone-specific) .xib file in the project navigator, then select File... --> Duplicate...
Name the new .xib file the same as your iphone-specific one, but append ~ipad to the name. All your previous connections in the view hierarchy should be unchanged in your brand-new iPad-specific .xib file.
You can use this tool I made, based on the answer from "arlomedia":
http://iphone.dizzystudios.net/ConvertToiPad
just give it the iPhone xib path
I've made an iPad app. Now, I'm changing some UI elements in the NIB. When I run the app in the simulator none of my changes appear.
I've tried touching the project before building. Nothing is working.
Can anyone shed some insight?
It seems you are not loading the correct NIB file, or more probably you have for gotten to make the right connections in you NIB file with the owner file.
If none of these are the case we are going to need some code that shows where you load you nib and/or a NIB we can inspect ourselves. :)
Try this:
Clean the target (⇧⌘K)
Delete the app from the Simulator
Build & Run as normal.
Make sure you save the changes in Interface Builder. I've found that on occasion I've forgot to save changes there, with predictable results.
In the Simulator menu, select "Reset Content and Settings…" which wipes out anything that was there previously. Xcode saves time by not installing anything it thinks is already there. This usually works fine, but occasionally can lead to out-of-date resources not being updated.