Debugging IBDesignable - debug selected views not working
Asked Answered
C

1

6

Recenlty I've made reusable class for rendering IBDesignables xibs in interface view.

@interface ReusableView ()
@property (nonatomic, strong) UIView *contentView;
@end

@implementation ReusableView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    [self setupXib];

    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    [self setupXib];

    return self;
}

- (void)setupXib {
    self.contentView = [self loadFromNib];

    self.contentView.frame = self.bounds;
    self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    [self addSubview:self.contentView];
}

- (UIView *)loadFromNib {
    NSBundle *bundle = [NSBundle bundleForClass: [self class]];
    UINib *nib = [UINib nibWithNibName:NSStringFromClass([self class]) bundle:bundle];
    UIView *view = (UIView *)[[nib instantiateWithOwner:self options:nil] firstObject];

    return view;
}

@end

So far everything was ok until today. I've changed literally nothing in my code (I've even rolled-back to master branch to be sure) and my xibs using this class are no longer rendering in storyboards.

In interface builder there is information

Designables: Build failed

but the show button does nothing, as well as trying to use Editor > Debug Selected Views. I am unable to hit any breakpoint in my class.

So far I tried:

  • cleaning derived-data
  • restarting x-code
  • killing Interface Builder Cocoa Touch Tool
  • full-restart
  • project clean (in between previously described actions)

Is it some kind of xcode bug or somehow it's my fault? Is it possible to debug Designables any other way than with Debug Selected Views option?

Columnar answered 25/7, 2016 at 8:56 Comment(2)
have you figured out how to do this? No, it is probably not your fault. Xcode is a piece of crap.Contrabass
I've been having the exact same problem for some time. The only solution I've found to date is to delete the contents of the xib file and recreate them. In my case, there is a particular label in one of the xib files that is usually the culprit. I have no idea why it gets corrupted, or how to determine which xib file the problem is in, much less which view is to blame, aside from laborious manually testing. It is extremely frustrating.Ablepsia
S
3

Xcode now shows IB build errors if you click on the "Show Report Navigator" then look at the Interface Build section.

IB Build Errors

Sauls answered 14/2, 2018 at 21:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.