3

This is a best-practices question.

When one makes a new Swift application for OSX, it builds a Main.storyboard and places that physically in the Base.lproj folder, but logically within the app's main "group".

I decided to separate different parts of the UI into different storyboards, so I added a Document.storyboard and Preferences.storyboard.

In retrospect it's not clear if this was the correct way to do this - for items that consist of a single window or view, should I use storyboards or just use XIBs? I've read the Apple documents but I'm not clear on the practical differences. Are storyboards "replacing" XIBs, are they the new hotness that I should use from now on?

Now I will be expanding the project with additional views, specifically a series of sheets used for editing certain features of the document. Should I put these all in a single storyboard, one XIB, or individual XIBs? Is there any strong reason to select one over the others?

And finally, when I added my storyboards, it placed them in the root of the project folder. Should these really be moved to Base.lprog?

Maury Markowitz
  • 9,082
  • 11
  • 46
  • 98

1 Answers1

4

This is something I've been thinking about, too. I've recently gotten into OS X development, so I'll share my amateur view of XIBs vs storyboards. To those of you that are more familiar with this, feel free to correct me if I'm mistaken.

Interface Builder inside Xcode seems to do a pretty good job of allowing you to put a skeleton in place, but doesn't always provide all the necessary customization options for a view. When using storyboards, I frequently end up with projects that are half visually based, and half code. It's like working on a cyborg.

Nibs/Xibs suffer from the same problem, but they don't even try to implement transitions. From what I can tell, they represent single windows, views, or menu items. This makes them simpler and more modular. You get to write the code that handles the wiring of them together, and, at first, it may seem like more trouble, but it actually feels like a benefit to me because of the level of control gained. Storyboards can do a lot of this for you, but I personally tend to prefer having it all together in the code.

The ideal solution, to me, would be for Apple to implement a more abstract form of user interface design: where each window (or iOS view, depending on the platform) was contained in a nib, and a Storyboard was only a transition mapping between the nibs. For example: You create all your windows and menus, and then use the storyboard to connect them all, but the storyboard can't edit any of the views details, only transitions and connections.

That being said, I'm quickly getting to the point where I prefer nibs and do all the other coding myself. If nothing else, I'm becoming a better programmer for it. Hope this helps!

definitelyokay
  • 377
  • 2
  • 14
  • This would also solve the practical problem that storyboards tend to be physically very large, which makes them very difficult to work with on-screen. This sounds minor but has proven to be a real problem in my workflow. – Maury Markowitz Apr 03 '16 at 13:40
  • @MauryMarkowitz Yeah, I completely concur. Good luck with your project :) – definitelyokay Apr 03 '16 at 19:14
  • What about the latest Xcode 8.3 release, I can't find the option to use nibs. Only storyboards are supported!?. I am also till now a nib user and transitioning previous developments to storyboards is painful! – Kader Mokhefi Mar 30 '17 at 15:12
  • @KaderMokhefi It works for me--you can add a new file of type "view" or "window" and it will create a .xib file :) – definitelyokay Apr 01 '17 at 21:08