Apple, please finish Interface Builder!

This post is a cry of anger towards Apple, and yet hope remained in me. I have been an iOS developer for 4 years now, and what at first seemed like a momentary imperfection, insignificant details turned into a Chinese torture with water over the years, and you and I use IB every day, well, or at least once a week.



Perhaps Apple does not deserve such criticism - the truth is, everything else, well, or almost everything else, is at their best. Excluding iTunes and the Apple developer portal (which, in recent years, nevertheless, has become much better), technologies allow you to focus on what you are doing, and not on how it will look in IE.

At first I did not use IB at all, it seemed so crooked and wretched to me after other visual editors. Even Macromedia Dreamviewer MX, IMHO, had a better chance of being called WYSIWYG editors for the UI. But several years passed, and a wonderful thing appeared - Autolayout - which is disastrously inconvenient to implement in the code. Little happiness in this code:

UIImageView *iv = [[UIImageView alloc] initWithImage:image];
    UIView *renderView = [[UIView alloc] initWithFrame:iv.bounds];
    NSInteger completedDistance = renderView.bounds.size.width * percentsCompleted;
    UIView *progressView = [[UIView alloc] initWithFrame:CGRectMake(completedDistance, 0, renderView.bounds.size.width, renderView.bounds.size.height)];
    progressView.backgroundColor = RGB_UICOLOR(255, 255, 255, 0.8);
    renderView.clipsToBounds = YES;
    [renderView addSubview:iv];
    [renderView addSubview:progressView];


but kind code

NSMutableArray *constraints = [@[] mutableCopy];
    
    [constraints addObject:[NSLayoutConstraint constraintWithItem:self
                                  attribute:NSLayoutAttributeWidth
                                  relatedBy:NSLayoutRelationEqual
                                     toItem:self.parentView
                                  attribute:NSLayoutAttributeWidth
                                 multiplier:1
                                   constant:0]];
   [constraints addObject:[NSLayoutConstraint constraintWithItem:self
                                  attribute:NSLayoutAttributeHeight
                                  relatedBy:NSLayoutRelationEqual
                                     toItem:self.parentView
                                  attribute:NSLayoutAttributeHeight
                                 multiplier:1
                                   constant:0]];
    [constraints addObject:[NSLayoutConstraint constraintWithItem:self
                                  attribute:NSLayoutAttributeTop
                                  relatedBy:NSLayoutRelationEqual
                                     toItem:self.parentView
                                  attribute:NSLayoutAttributeTop
                                 multiplier:1
                                   constant:0]];
    [constraints addObject:[NSLayoutConstraint constraintWithItem:self
                                 attribute:NSLayoutAttributeLeading
                                 relatedBy:NSLayoutRelationEqual
                                    toItem:self.parentView
                                 attribute:NSLayoutAttributeLeading
                                multiplier:1
                                  constant:0]];
    
    [self.parentView addConstraints:constraints];


plunges the soul of a developer into gloom and depression. In IB, the autolayout setting at the beginning is also sugar, but as time goes on you get used to it, you start to force yourself to not notice terrible jambs, endure small flaws until ... you don't have a tantrum and the number of blunders that are uncorrected over the years does not exceed all reasonable limits. But there is no alternative, the format is undocumented, there will be no third-party tools! Here is my shortened little black list:

  • give a scale of at least 200%! If there are a lot of small elements on the view, you can go crazy poking at microscopic views with a mouse, and choosing from a long list is also not a quick task;
  • visually you can set far from all the properties of the view, well, if 30%. I recall Borland Delphi and its magical Object Inspector, in which you could create almost any view, and it looked almost the same as in runtime. In IB, the views look like shit, or rather, a set of abstract squares of Picasso’s hand. But there is a flag Hidden (EVERYTHING, EVERYTHING expose it programmatically depending on the events!) And Stretching (I don’t even know what it is);
  • Previously, I rolled a view (UIView) as a table header, now I need a UITableViewHeaderFooterView. Okay, where do I drag her to the Xib? Right, out of nowhere, write with your hands! And if you decide to slip the table to UIView-hu, I will be offended and crash;
  • There is no intelligible XML that IB generates. Manually it is impossible to correct or hold. You begin, God forgive me, to envy Android developers - they have a pretty shitty visual editor, but if something happens, write with pens - no one will be offended!
  • After changing the view class, its “IB-super” does not change, which leads to glitches and crashes of both your application and the whole xCode. Suppose you create a UITableViewCell with many subviews and constants for half an hour, and suddenly you realize that you need a CollectionView and, accordingly, its cell. There is only one way out - until you have spent an irreplaceable supply of vital energy, delete the xib and recreate it from scratch. This is the only way Apple can guarantee your application’s performance;
  • Where are the coherent best practices on storyboards, especially if the application is not a notebook or calculator? When you try to port an application on an iPad that an Indian or compatriot, keen on Indian culture developed exclusively in the storyboard, you cry with bloody tears. Table cells need to be forbidden to be created in storyboards, Xibs and only Xibs! The system should have minimal protection from the fool;


Not only all of this, we recently added a new pain in the ass:

  • The biggest IB interface (sorry taftology) from all previous reincarnations! Constrains often pretend to be Leading space (apparently, such a fish in its own xib). The only way to understand what it is to open the Assistant Editor’s window a bit, but!
  • At the same time, our canvas begins to leave smoothly up and to the left!
  • In the year that has passed since the release of iOS 6, everyone is already accustomed to the fact that IB itself delivers all unnecessary constructs to logical integrity, and here it defaults to doing it implicitly during xib compilation! So it’s impossible to predict what the introduction of only one width will lead to. I advise you to use the "Add missing constraints" command and typeset in the old fashioned way.


To Apple’s credit, it’s possible that the constructs stopped moving from each sneeze to the mouse, but it brought me to a nervous breakdown 4 times in xCode 4, and my partner’s friend even died of a heart attack.

Those who recently discovered iOS sing in a chorus of “finish!”, Sacredly believing in the icon of the apple and Steve Jobs. To which I object: “They won’t finish it!”, They always have a dozen more important things to do. Really important, beautiful things, but Apple - we deal with IB every day, take pity on us, ordinary mortal developers!

In parting, I want to offer an interesting poll:

Only registered users can participate in the survey. Please come in.

How do you typeset UI in iOS?

  • 23.6% I do everything in the storyboard 150
  • 17.3% I use Xibs and storyboards wherever I get 110
  • 18.0% I use only Xibs 114
  • 41.1% I hate IB, real programmers write code! 261