Extracting nibs/xibs from storyboards (iOS)
Solution 1
I found that the simplest method was to copy and paste the items out of the storyboard, one view at a time, and recreate the view controllers for each one.
However, for anybody who does this, note that you have to make a xib for MainWindow in addition to all of your other XIBs, and hook it up accordingly, including setting up the window and app delegate. Storyboards handle all of this for you, so when you try to avoid them, you have a lot of manual setting up that creating non-storyboard projects from the get-go handles for you. Don't do what I did, and try to make your root controller your main view controller, because it will go nuts saying things about how UIApplication isn't key-value compliant for individual properties of your XIB.
Solution 2
Xib files cannot be extracted from the storyboard but you can instantiate UIViewControllers out of the storyboard by instantiating your storyboard into a UIStoryboard Object and getting the UIViewController via its identifier, here's how I do it:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:
@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
UIViewController *myController = [storyboard instantiateViewControllerWithIdentifier:@"myId"];
hope this helps.
Solution 3
As a few others have suggested, your best bet is to clone the views from storyboard into an XIB.
Solution 4
You may not be able to extract the .xibs from the storyboard, but try this. Have your .xib based project open and create the empty .xib files for your views and also have the storyboard project open at the same time. Select all the UI elements in your storyboards scene and simply drag and drop them over to the .xib based project. I have done this the other way around (moving from .xib to storyboard) with no problems.
Solution 5
It's not possible to get xib files. Your storyboard is compiled to nib files and packaged into a storyboardc file within your app bundle.
To locate the nib files select your built executable in Finder and right-click 'Show package contents'. Navigate to the en.lproj directory and find the storyboard.storyboardc file. Right-click 'Show package contents' again on the storyboard file and you will find your nibs. They will not be much use to you though because they are compiled binary nibs.
Tim
iOS Developer. Used to work at a place, decided working at home was cooler.
Updated on July 13, 2022Comments
-
Tim almost 2 years
I have created a simple project with a storyboard, and now realize that they don't support iOS 4.x and that I would like users with these devices to be able to download my app. The app is just a flipside view controller, and is fairly simple but if there's a way to just extract the XIBs from the storyboard I'd much prefer to do that than recreate it.
tl;dr: getting .xibs out of a .storyboard?
-
Tim about 12 yearsThanks, but my primary goal was to avoid the use of storyboards in the project after it was already built with them - I had to add support for 4.0 for which storyboards can't be used.
-
user4951 over 11 yearsThere is no way to use Outlet to refer to controller with outlet isn't it?
-
Firdous about 10 yearsif you could share the example project, would be great!
-
Amr Lotfy over 8 yearsNice, this is the simplest way until apple adds export to xib option on a selected view in a storyboard.
-
etayluz almost 8 yearsHere what you are doing is taking the view from the scene and making it a subview of the XIB's View. Can you do better by replacing the XIB's view with that from the scene? I have tried this - and it seemed to work
-
Davyd Geyl about 6 yearsThis does not answer the question: how to extract the XIBs from the storyboard. Also, it give a wrong answer "Xib files cannot be extracted from the storyboard", when in fact they can be.