Interface Builder is bad and getting worse

Hi,


I've been a Mac developer since the late 80's. I've had my name on somewhere around 500 commercial products spanning every part of Mac and iOS software. I ran the largest Mac source code repository on the planet (4Gb of raw source code on DevHQ) until Dr. Dobb's Journal took it over. My point is that I've been here for a long time now.


This morning I spent *FOUR F*CKING HOURS* trying to make a @#$# button correctly span the width of a view, without screwing up everything else I delicately placed in the view.


This is *PAINFUL*.


Unity3D, by comparison, has an almost effortless UI system. I mocked up *THIS* UI in Unity so I could test it, before trying to make it work in Xcode. Think about that.


This is shameful. Look, Interface Builder has never been particularly *great* at UI design, but it wasn't this bad.


I know it's not just me. Every client I've worked with in the last five years has had problems navigating Interface Builder. Every time there's an update, I pore over the documentation and try to figure out what *BROKE* and what new, stupider, way of handling UI issues you've invented. I do this because my clients call within days of each major Xcode update to ask how to do something they used to do.


And if I'm having problems with this, I guarantee this is a stumbling block for new users.


Here's a simple solution: The last time I was at WWDC, you had a team of UI specialists I could go sit with who would help me find roadblocks my users might encounter in my UI. Please, Apple, have your UI specialists spend some quality time on Interface Builder.


Have some **** pride, people.


Now I'm going to go randomly click on crap and see if I stumble over something that works better than following the directions.

-Chilton

Answered by HyperNovaSoftware in 92843022

I do everything in code so I can place everything exactly how I want it.

IB is a complication I'd rather not deal with.

Most dedicated Mac developers have at least some design experience.

Actually, most dedicated Mac OS developers are both developers and designers. I know very few "I'm just a developer" style developers on the Mac side of the fence.

"I think many people complain about IB are mainly "pure programmers", who have much less understanding of pure design thinking and problems ..."


Every Mac programmer I know was either a designer first, or is still a designer. Specialization is for bugs.


-Chilton

> I think Interface Builder works fairly well for the most part, mainly when you are not using Autolayout.

Hmm, if you don't use autolayout, doesn't it just add more time consuming work to make the interface in IB? Because if the layout logic is handled in code, then IB is used just as a visual header file, am I correct/wrong?


> For certain layouts, it is required that a 3.5 inch screen has a slightly different layout than larger screens.

Isn't (C, C) size class exactly this? ... As the width would be the same for most other phones, you only neded to handle smaller height.


> They could have just allowed us to switch and quickly make device specific constraints.

That was exactly my pointof view before having to deal with all the split ratio (1/3, 2/3 and 1/2) ... Then you realise that a current gen iPad at 1/3 is exactly as wide as a non-plus iPhone. So rather than having device-specific code, having a size-specific code makes everything dynamic and easily adaptable for any interface (kind of like Responsive Design for websites).


I have some comments on your points, hope it helps you as I've had the same struggles before switching to 100% IB/Autolayout/SizeClasses:


1) For orientation, besides the iPad's full screen, it's better to avoid thinking about it (the orientation) from now on. As an iPad in Landscape (supposedly having a wide-scree estate), can load your app in the 1/3rd area, thus having the same screen estate as an iPhone in portrait (that's the reason Apple removed all "rotation/orientations" methods from iOS8 for willTransitionToSize methods).

When you create constraint, you can just have them "installed" or not in specific combinations.

- It's better to not have two conflicting constraints active at the same time (for ex, rathen than C,Any and C,C. It's better to have a C,R and C,C)

- Using priority can help avoiding conflicting constraint, and you don't have to activate/inactivate them in code.

- My best advice to be sure you won't have any conflict during runtime, is when designing in IB, to switch the preview to each of the other 8 Base/Final Values. If there is any conflict, you'll get IB to complain about it (I'd hoped Apple make IB complain when current constraint can conflict in any situation, not only currently previewed Size Class).


2) That's my biggest complaint. I did understand why they did that when split view came in play (a split iPad Pro in Landscape = 2 iPads in Portrait), but obviously,when it's in full screen, it's wider, so maybe an extra Size Class (W, for Wide maybe) would be very welcome.

- One solution that works is to give ids to your constraint, and in code (viewWillTransitionToSize: or willTransitionToTraitCollection:), check size.width > size.height only in R,R Size Class and activate/deactive your constraints by id.

Still a flaw from Apple I think.


3) I kinda disagree with this point, as with all the aspects ratio of different phones (3.5", 4", 4.7", 5.5") and all the different splits, + God fobib new devices from Apple. It would be a real mess to have to design for each screen (the aspect ratio of a 1/3 split of iPad in portrait = 2x a 3.5", and 1.5x a 4" in landscape).

While currently with the Size Classes, designing an App got really close to WebDesigning with Media Queries.


4) Care to share an example? Personally, the only case where I've had to subclass was with buttons/Labels, but more because Autolayout than size classes, it's that text doesn't grow with the button, unless you put a huge font, in which case it doesn't scale down correctly (it can "fit width" but not height, which is especially a problem when you support many languages such as Asian ones).


5) Any open rdar or example project? I'd like to have a look and hopefully find a workaround.

The similar problem I've seen (rdar://23105634) can be solved pretty easily by "removing at build time", and install it only in the specific Size Class. Of course this forces you to have constraints on all object in the view and not have any orphen, but as a good practice I've always put rules on all objects.


6) This is a big flaw in Xcode I guess, not only in IB but also in code. You can still use methods that are not available in your build target (in code), the same way you can use constraints that are not available (IB).

There is no workaround besides reading documentation of each constraint and see which version of iOS it's available in (example, "Aspect ratio" constraint on images doesn't work in iOS7, and IB won't even complain by a note or warning).

I guess Apple could make it easy by removing options unavailable in your build target or at least throwing a warning.


7) One thing that can speed your productivity fairly is to use the preview pane, and load each device twice (for Portrait/Landscape). You'd need a good machine and a large screen (iMac Retina 5K makes it a breeze), but you don't have to worry about building/rotating on each device/simulator which is time consuming.

Now, the major problem is that the Preview's devices are always on the latest iOS version your Xcode supports, which means you'll still have to build on device/simulators with older iOS version (if you support ios' downward). But the little good news is that if you use only constraints available in your build target and it looks fine in Preview, then you'll be fine on device (hopefully, while Apple adds new constraints options, they deprecated none, finger crossed).

Now, there are many bugs and flaws one should be aware of, but nothing blocking, and still from productivity, portability and maintenance points of view, much faster to design on IB then care about the few lacks in code, and not having to worry about the interface if a new screen size/split size appeared.


One major bug: The new UIStackViews don't react to Size Class/Trait Collection (only even numbered ones, which means Apple's update loop was messed somewhere), open rdar://23105634


One major lack: The ratio can't be modified with size classes, so we can't make a view "half" of the screen in landscape and two thirds in portrait for example.

Hopefully, we'll get more complex combinations in the future (like boolean codes, for example width of A = 2x width of B of B.width > C.height, and 3x height of C otherwise ... it's still doable, but need 3 constraints and complex priorities).

Unsure about this, IB has been broken since 7.1 came out, but finally fixed in 7.2

For the extra 20 points, I guess you can disable the "relative to margin" project-wise, wouldn't that help?

Waow, that's probably the boldest statement I've seen on internet (bolder than some Apple fanboy blogs who try to make Mac developers look like coolest/smartest/most charming and successful lads on earth).


I guess your statement doesn't apply to the 250+ programmers just in my current company (I won't count other companies I've worked for/with). Unless of course you don't consider people specializing in network/connectivity, IC/SOC programming, etc as being "Mac programmers" but just some "bugs specialists" (I have yet to find a single "X domain bugs specialist" course in any known and less known IT University/college ... And I did search before posting the comment).


I guess you don't consider all the teenagers developing successful apps on iDevices as "real programmers" either? Or do you discriminate on mobile developers and elite "Mac programmers"?


Well, that's maybe true for freelancers (like I was), but let me tell you that the few freelancers who have to learn everything to make something are a minority in the IT world, there are far more people being specialists (no, not in bugs) in many specific and narrow domains especially in large corporations. You can't expect a radiowave theorist to know how to design a user-friendly UI even though he writes the most complex and low level interface code.

Or maybe we're just talking about different things, such us you meaning "Pattern Design (programming)" and me meaning "UI Design (visual design, color theories, UI/UX, etc)".

> I think Interface Builder works fairly well for the most part, mainly when you are not using Autolayout.

>>Hmm, if you don't use autolayout, doesn't it just add more time consuming work to make the interface in IB? Because if the layout logic is handled in code, then IB is used just as a visual header file, am I correct/wrong?


Yes, IB is basically used as a visual header file when I do it this way (you save a few lines of code since you don't have to instantiate views in code, but yes). Depending on the type of layout you have, I find writing layout code can be much quicker than wiring up constraints and resizing view controllers to test those constraints on every device in IB (or running on every device…and all supported orientations). Also I find it easier to make changes. With auto layout you have to be very careful when modifying the UI down the road. New constraints can mess up your old constraints.


> For certain layouts, it is required that a 3.5 inch screen has a slightly different layout than larger screens.

??Isn't (C, C) size class exactly this? ... As the width would be the same for most other phones, you only neded to handle smaller height.


Yes. You only need to handle a smaller height. For some view controllers you can get away with scrolling content on the smaller screen but not always. If you have a menu with a 5 buttons stacked vertically, you may hit the bottom on 3.5 inch iPhone. Depending on the layout you can do:

1) Take optional buttons out altogether on the shorter screen (I don't like).

2) Move a few buttons out of the vertical stack on the smaller screen into a UIToolbar (makes sense).

3) Use a smaller font size on the smaller screen so they fit and stack the buttons the exact same way as the larger screens.


For all three approaches I mentioned above, there is no direct way to do it in Interface Builder. You can subclass the view and sniff the screen which isn't great. At that point, you may be better off just writing the layout code yourself. Since layouts are different and one approach won't always work, I'd like to be able to create and associate custom size classes with devices. Some layouts it'd be nice to have the iPhone 6 Plus and iPads share the same size classes, while on others you may wish to have the 6 plus have the same size classes as the iPhone 6 and the 5 ect. This would be much more powerful.

> They could have just allowed us to switch and quickly make device specific constraints.

That was exactly my pointof view before having to deal with all the split ratio (1/3, 2/3 and 1/2) ... Then you realise that a current gen iPad at 1/3 is exactly as wide as a non-plus iPhone. So rather than having device-specific code, having a size-specific code makes everything dynamic and easily adaptable for any interface (kind of like Responsive Design for websites).


Well, I think there should be a default configuration (perhaps like the way things are now). But if the developer determines that the default way size classes are is not going to suit the layout, he should be able to easily modify the defaults and customize it. You have to eat the default size classes, or subclass more views than you probably would want to and screen sniff to customize.

Even if you are not using size classes, you should make your layout code work on as many devices as possible (make the layout code as responsive as possible). Apple is deciding what size classes best suit the devices that they are associated with. The defaults are reasonable but it should be easier to customize. As bad as CSS/HTML/JS even CSS has support for applying styles based on the dimensions of the browser.


>I have some comments on your points, hope it helps you as I've had the same struggles before switching to 100% IB/Autolayout/SizeClasses:

>>1) For orientation, besides the iPad's full screen, it's better to avoid thinking about it (the orientation) from now on. As an iPad in Landscape (supposedly having a wide-scree estate), can load your app in the 1/3rd area, thus having the same screen estate as an iPhone in portrait (that's the reason Apple removed all "rotation/orientations" methods from iOS8 for willTransitionToSize methods).

When you create constraint, you can just have them "installed" or not in specific combinations.

- It's better to not have two conflicting constraints active at the same time (for ex, rathen than C,Any and C,C. It's better to have a C,R and C,C)

- Using priority can help avoiding conflicting constraint, and you don't have to activate/inactivate them in code.

- My best advice to be sure you won't have any conflict during runtime, is when designing in IB, to switch the preview to each of the other 8 Base/Final Values. If there is any conflict, you'll get IB to complain about it (I'd hoped Apple make IB complain when current constraint can conflict in any situation, not only currently previewed Size Class).


I agree. The idea is to re-use as much as you can for the most layouts. One project (which I haven't finished yet) is using Autolayout in IB and I was able to get a good amount of layout done in IB…but I really feel like I can write flexible layout code faster most of the time.


2) That's my biggest complaint. I did understand why they did that when split view came in play (a split iPad Pro in Landscape = 2 iPads in Portrait), but obviously,when it's in full screen, it's wider, so maybe an extra Size Class (W, for Wide maybe) would be very welcome.

- One solution that works is to give ids to your constraint, and in code (viewWillTransitionToSize: or willTransitionToTraitCollection:), check size.width > size.height only in R,R Size Class and activate/deactive your constraints by id.

Still a flaw from Apple I think.


Yeah. I agree.


3) I kinda disagree with this point, as with all the aspects ratio of different phones (3.5", 4", 4.7", 5.5") and all the different splits, + God fobib new devices from Apple. It would be a real mess to have to design for each screen (the aspect ratio of a 1/3 split of iPad in portrait = 2x a 3.5", and 1.5x a 4" in landscape).

While currently with the Size Classes, designing an App got really close to WebDesigning with Media Queries.


Perhaps it can get out of hand at a certain point, but only if you don't reuse anything and you really do every constraint one device at a time. Even with the default configurations now, you are encouraged to make as many constraints as you can for all devices. Then you do the size class specific constraints when you need to so you don't duplicate work. I think the best solution would be to apply reasonable behavior as the default configuration, but make it easy for developers to create custom size classes and associate them with devices for complex cases at the developer's discretion.


4) Care to share an example? Personally, the only case where I've had to subclass was with buttons/Labels, but more because Autolayout than size classes, it's that text doesn't grow with the button, unless you put a huge font, in which case it doesn't scale down correctly (it can "fit width" but not height, which is especially a problem when you support many languages such as Asian ones).


I mentioned some examples earlier in the post responding to one of your comments. On 3.5 inch iPhone, on one layout I'm able to stack 5 buttons vertically just as I would on the larger screens (and it looks good), but only if I use a smaller font size. As far as I know, there's no supported way to give the 3.5 inch iPhone a diff. font size in IB as the other devices that share the same size classes. If I make all the devices use the smaller font size, we are not longer taking advantage of the bigger screens. Too much dead space. I can think of more, but I only have time for that right now.

Hi, thank you for the detailed answer, I'll add some thoughts:


> Yes, IB is basically used as a visual header file when I do it this way (you save a few lines of code since you don't have to instantiate views in code, but yes).


That's what I thought. And I don find this a bit messy on the long term.

I've had to update large projects where many devs did that, and it was quite messy, especially when the unused elements are not removed. You end up with a view containing dozens of elements with zero visibility, as appearence is done in code. Maintaining can become a nightmare.

(thanks to that, since Xcode 6 apple provides the IBDesignable for elements done in code to appear automatically on the view, with no need to declare them in IB at all).


> For all three approaches I mentioned above, there is no direct way to do it in Interface Builder.


Actually, from what I see, the problem here isn't IB, but the design choice. That's why the design should be handled by the design team (for my teams, I split the work where designers only touch storyboards and XIBs, and programmers touch the code, with merge requests when IBOutlets are declared, this avoids conflicts and everyone can focus on its work without worrying).

Now, I do understand that not every project has large teams on it. So one good thing I see is the new stack views for iOS.

One thing can be done on your array of buttons is that if they are in (C, C), you switch the axis between vertical and horizontal which can be done in IB alone, but can be done in code if orientation for the 3.5 and iPad are required ... (That's where I'd like complex expressions for IB, such as a boolean comparing height and width of parentview or the screen).


> Well, I think there should be a default configuration (perhaps like the way things are now). But if the developer determines that the default way size classes are is not going to suit the layout, he should be able to easily modify the defaults and customize it.


Well, while I agree that giving more contrl to developers is the best thing that can be done, but in this specific case, it's Apple who decides which sizes are available for the end user (both screens and splits), so I guess it's fine if they decide which are the steps.

Now, when you make your layout, you can easily customize only the class that you want, and let the others act normally, for example, most of the designs I've received have two layouts depending on orientations and a specific layout for the 3.5 or iPads, so my size classes are all set to (Any, Any) with a 600 priority, then only the one extra hack for the specific class at a higher priority.


Of course, I regret more choices, such as a "Large" size class for iPads, it would help differenciate a landscape 1/2 split and full screen (now both receive (R,R) and there is no way to differenciate between them even in code).


> As bad as CSS/HTML/JS even CSS has support for applying styles based on the dimensions of the browser.

I aggree but that's because a browser can beresized on whim, while size classes (from the end user point of view) are limited to few choices (1/3, 1/2 and full, and it depends on the device). Also, which different density of pixels, it can be hard to decide few things (I've worked on projects where the buttons have to adapt to their image, and the images @1, @2 and @3 have completely different sizes not based on aspect but on screen lisibility ... this was an awcward one for normal apps, bur completely normal for games).


Also, the steps in CSS depend largely on which framework you'd use (unless you code everything from scratch), and the philosophy is quite close to current size classes with the grid system (here also, the number of steps is greatly different depending on the framework, Foundation for example doesn't handle eXtra Small sizes while Bootstrap does ... It's hard to find a system that pleases everyone).


> but I really feel like I can write flexible layout code faster most of the time.

That's nice, of course it's better to chose what gets your work done the fastest and easiest way. But when in large corps and having projects that extends on many years accross many developers, IB saves the sanity of many.

I find it also easier to change the interface or adapt to new layout changes more easily in IB.


Of course, my point of view holds true especially when you have dedicated designers, as it's their job to have the UI/UX correct on all devices , orientations and splits. Programers can focus and backend code only, and specific scenarios (activating some constraints depending on orientation of iPad for example, but even in this case, the constraint should be done in IB, and the designer should have verified that activating it doesn't break any other constraint).


> Even with the default configurations now, you are encouraged to make as many constraints as you can for all devices.


May I ask where you have seen that? Because, from what I understand from your point, I was told the exact opposite at the WWDC from an UIKit engineer.

The idea is to do the minimum constraints possible for a design to work (no complaints from IB), then add only the specific override point, by switching the IB display to that size class, and be sure that are no warnings/erros in IB (somehow like in CSS where you append an override only for the specific element in a specific scenario).


> I think the best solution would be to apply reasonable behavior as the default configuration, but make it easy for developers to create custom size classes and associate them with devices for complex cases at the developer's discretion.


Completely agree with that. Actually filling a ticket for an enhacement: A "Custom expression" in IB, where we can input things such comparisons and if/else expressions.


> As far as I know, there's no supported way to give the 3.5 inch iPhone a diff. font size in IB as the other devices that share the same size classes.


iPhone 3.5 would have the same height in landscape as the 4 and 4.7, in which case adding a specific (C, C) expression would work for all.

You can explore thestack views if your project is iOS9+ only.


Now, buttons are pretty hard to handle for internal font size (that's the only example where I had to subclass), on other things (labels for example), giving the font size a large value then allowing it to scale down (or a minimum font size) and let the container scale automatically can fix things.


My projects are mostly for South East Asia, so even when subclassing it's pretty hard to get the correct size and baselines for the custom fonts. The work around is to have a button without text and a label on top of it, both centered and equal width/height of their container view, it solves the problem but hard to implement and maintain (UIStackViews do exactly the same things with ease, but for iOS9+ only projects).

We quit using interface builder when Autolayout was introduced. It was just too painfull to work with a team on an interface with storyboards and nib files.


We had insane issues when merging our work. If a team member just clicked somewhere at the wrong spot the whole layfile was wasted. Debugging the interface when a constraint breaks is still a nightmare.


The whole autolayout system is just a crazy mess to work with. No wonder Facebook is doing it's own stuff now. We do it like Facebook and go our own ways. This direction where Apple goes here is not good in our opinion.

That's why we call it the Grim Reaper. It brings death to your layout, death to your app.

Agree - I've never had so much trouble getting up to speed on a layout tool.


I don't understand why Apple always has to go their own way. Dozens of good layout tools and languages out there - IB? Objc? Swift? Blows my mind, and I don't think I will be writing for Apple again after next year. Enough is enough.

I agree that the easiest way, in terms, of doing stuff is by using Interface Builder but I have to agree to the poster, Xcode is a real piece of stinking crap and Interface Builder should have its name changed to Rough Sketch Nightmare Builder. Xcode was relatively "good" until release 3. Then Xcode 4 was launched and the nightmare began.


Now I understand why a guy called Bret Victor, a former Apple employee left Apple. The guy is a master of having good ideas for development and he was probably very frustrated of having such ideas and have to deal with a piece of crap called Xcode.

Constraints are an absolute mess. I took me like 4 hours the other day just to center a ******* text label in the view controller -- absolutely ridiculous.

self.label.center = CGPointMake(self.view.frame.size.width/2.0,
                               self.view.frame.size.height/2.0);

This is on the LaunchScreen.storyboard so that wouldn't work. For some odd reason, I had no problem centering the text label in a previous app that used a LaunchScreen.xib.

I'm iOS game developer. I developed many games for iPhone's and iPad's. In the beginning UI design I've done in the code. Using relative coordinates solve all possible problems and UI looks perfect on any device. But development UI in code is honestly slow, inconvenient and the most important thing it's not WYSIWYG.


I'm using cocos2d's engine by the way all this time. And so, once I saw an editor - CocosBuilder. It was a key change in UI development for me.

With this simple editor I was able to desing any types of UI in no time. All WYSIWYG and it works perfectly on any device like 4:3 or 16:9.

All thanks to simple thing like this:


http://i.piccy.info/i9/8193d70008d23d77fa4fea0143424b43/1484312351/29176/1095328/Screen_Shot_2017_01_13_at_2_58_23_PM.png


And now I decided to develop enterprise applications for iOS. Done a couple of simple apps for myself and currently I'm working at fulltime and dealing with IB.


So, what I can say: IB is just really really bad. Awkward. Uncomfortable. Inconvenient. Just don't want to use it at all. I can't beleive that it was done by Apple...


Please, re-create it from the scrath. Make it useful, nice and simple. These "constraints" - for simple scene I must to add in average 40-80 constraints for just simple layout of a 4-5 buttons, some views and scroll. In that CocosBuilder I can create same screen in 30 seconds and without any complex structures. Well, IB system itself is bad: selecting objects, drag and drop, moving objects ... ehm, I can't even hide some view and there are many more awkward things..

Interface Builder is bad and getting worse
 
 
Q