Which is more efficient way? StoryBoard or XIB?
My point of view that a professional developer MUST use xibs
, but a hobbyist, new to programming, developer might be helped if he uses storyboard.
Storyboard
After a 3 year project work with a single storyboard I can tell a lot of disadvantages
:
1) It REALLY gets VERY VERY slow to build even for a very very very little think ( every single view in it must be rebuild ). Also it is very hard to edit even with an iMac with 8 or 16 gb ram if the Storyboard gets bigger. It's even hard to open it.
2) No reusability. There is no way you can import immediately a View/ViewController with its view to another project. It will be connected with other ViewControllers, Views Or Segues and that will make it like a big "don't touch" think.
3) there is so much lag when the project gets bigger even for the smallest layout constraint to be added or edited, that you never want to touch it.
4) If you use the cells by automatic cell addition of storyboard, you cannot use the same cell build in two points.
Advantage:
1) Automatic Cells (But this is also a disadvantage because a cell cannot be reused as is to another view)
2) Segues etc would make it easy for someone to understand with a single point of view what is happening.
Xibs:
1) Fully portable.
2) Open/Edit/Build SO MUCH MUCH MUCH faster than a storyboard that gets bigger
conclusion:
If you are a hobbyist developer who will make an app for his business for fun, you should use storyboard because it will it easier to understand things. BUT, if you a professional developer, you MUST use xibs for VCs, Cells, etc, Because this is the only way to make them really reusable and portable, in order to gain so much time for the next project, or even when having to make a little change or build the storyboard again.
Explanation why xibs are more "reusable and portable" for me: Things in programming must be kept in different models, files, entities, modules. One must be as least dependent on another thing as it can get
It is not to tell which one is the best. because which one is good to tell based on team requirement.
If you are a single developer, it is good to use storyboard because it consumes less time. If the team consists of many developers, use xib, otherwise, it is not easy to merge the modules/tasks.
xcode-using-storyboards-and-xibs-versus-creating-views-programmatically
Using XIBs
Advantages:
You can quickly put together a UI
Straight-forward implementation for small apps with a minimal number of screens
You can have separate XIBs for different localizations (ie. languages or countries)
Great at laying out elements and visually spotting misalignments. It’s easy to make a slight adjustment to the layout
Disadvantages:
It’s difficult to merge conflicts when working in a team environment (hard to diff, merge and read)
Highly dynamic views are impossible to describe as a XIB
Performance wise, it’s slower than creating views through code because the xib needs to be read from the disk and analysed/parsed
XIBs lack customizations that you can do in code such as Quartz stuff (drop shadows, round corners)
Harder to debug (i.e. if you forget to make a connection in Interface Builder or make a wrong connection)
Storyboards
Advantages:
Storyboards are nice for apps with a small to medium amount of screens and the requirements for navigation is relatively straightforward between views
You can mock up the flow of an application without writing much, if any, code
Disadvantages:
Storyboards are not compatible with pre-iOS 5 so it makes supporting iOS 4.3 impossible
It’s hard to work in parallel in a team environment because everyone’s modifying the same file
Along the same lines, merging conflicted storyboards in GIT will be a pain
People have experienced bugs in Xcode with the usage of storyboards (eg. having to frequently flush the DerivedData folder because of inconsistencies)