Why I stopped using storyboards and Interface Builder

Before you start lighting up the torches: yes, I have used Interface Builder before, extensively. Actually, up until a few months ago, I could not imagine creating a project without my beloved storyboard. I had looked a little into laying out constraints in code, and the syntax alone had scared the hell out of me. So you can imagine my surprise when, on my first day at Samsao, I learned that our guidelines explicitly banned the use of the Interface Builder. As my colleagues started explaining why that was, all I could think was: but it’s so much easier with IB!

And yet, a couple of weeks after letting go of the storyboard, I couldn’t imagine myself ever using one again.

Now if you’re a IB fanatic, you might just peg me as an extremist and ignore everything I say from this point on, and that’s fine. But if you’ve maybe wondered if there was a way to get back those 30 minutes a day you spend waiting on your heavy storyboard files to open up, then this post is for you!

So without wasting any more of your precious time, let’s get to it!

They are slow

If you have a lot of patience and like doing breathing exercises while waiting on your IB files to open, great for you! Personally, every time I used to try opening up a storyboard, all I wanted to do was bash my head against a wall. I know, I know, developing my patience is a work in progress.

They are hell to work with in a team setting

If you’re a freelance/indie developer or developer to-be, then this one might not have affected you yet, but if you’ve ever had to deal with a merge conflict on a NIB file, you know what hell feels like. With UI code, it’s a breeze!

They complicate code reusability

In code, if you have 5 screens that look almost the same, it’s so easy to use a protocol to efficiently reuse your UI code between them. With a storyboard, good luck figuring out how to share outlets and actions!

They can get really messy

One image speaks a thousand words. What the hell is even going on here??

SnapKit makes writing constraints in code so easy!

Okay, so you’ve read a thing or two about Visual Format Language, and it made you cry a little bit…

customView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat:"V:|-20-[customView(>=70@500)]-[customView(==customView)]-30-[customView]-|")

But if you know about SnapKit and how straightforward it is, you really have no excuse!

customView.snp.makeConstraints { (make) in
make.top.equalToSuperview()
make.centerX.equalToSuperview()
make.width.equalTo(70)
make.height.lessThanOrEqualTo(200)
}

UI code doesn’t get any sweeter than this!

To conclude

Yes, storyboards are easier for beginners t0 get into, and they are great for quick prototyping. But if you’re working on professional, large scale projects, I honestly can’t find a single good reason why someone would prefer using them instead of writing the UI in code.

If you’re curious about how to setup a project without storyboards using SnapKit, check out my new blog post about that!

Now I know most of the IB/storyboard fanatics out there still think I am insane, and if you’re one of them, I’d love to get your input, shoot me a comment!

Cheers and until next time!