Should you use Interface Builder and storyboards or write all your UI in code? This topic has been debated A LOT. There are good arguments on both sides, and every team's and project's needs are different. I'm not trying to convince you why one approach is better than the other, but rather share why we prefer not to use Interface Builder at Instabug, even with Xcode 9 and all the enhancements to Interface Builder over the years.
When I refer to using Interface Builder, I mean using either one of the two methods it offers: storyboards or separate Nib files. While both methods are a bit different and each one has some advantages over the other, this post discusses using either of them versus writing everything in code.
Merging and code reviews
Interface Builder files aren't human-readable, which makes merge conflicts very hard to resolve. It's not impossible to do, but it's not something you do with confidence like resolving a merge conflict in code.
Another problem with Interface Builder files not being human-readable is that you cannot review changes done to them when doing code reviews, which means that unwanted or unintentional changes to UI may happen and slip by in code review.
Reusability with interface builder and storyboards
Interface Builder makes it a lot harder to create reusable views. Using storyboards rather than standalone Nib files makes it even harder. Doing something as trivial as reusing a UITableViewCell prototype in two different view controllers is simply not possible.
Readability and maintainability
If you use Interface Builder and you have to modify a UI or fix a bug in it, you'll have to keep jumping back and forth between code and Interface Builder due to the fact that all the customizations done to a view cannot be done in a single place. This quickly becomes frustrating and confusing. On the other hand, if the UI is created in code, it becomes so much easier to see how and when a view is created and customized.
Auto Layout
Since we prefer not to include any third-party dependencies in our code, we cannot use things like SnapKit or PureLayout, but we think they are excellent options for apps.
Dependency Injection
While that works, it's complicating something that should be as simple as passing a few parameters to the view controller's init method.
Conclusion
Again, every team has different workflows and preferences, so writing all UIs in code might not make sense to everyone. In fact, I do recommend using Interface Builder for anyone that's starting to learn iOS development. They are an easier approach to start with, and they let you get something up and running faster.
If you'd like to get your feet wet and start building some UIs without using Interface Builder and storyboards, check out this tutorial from Aly Yakan, our iOS SDK engineer.
Learn more:
- How We Migrated Our Front-End While Scaling at Instabug
- How We Migrated Our Massive Crashes Database
- Why We Automated Our Front-End Testing at Instabug
- Mobile App Testing Vs. Mobile SDK Testing: What is the Difference?
Instabug empowers mobile teams to maintain industry-leading apps with mobile-focused, user-centric stability and performance monitoring.
Visit our sandbox or book a demo to see how Instabug can help your app