6

I'm working on a project with 100+ source files. I decided to implement a reusable custom view whose layout I can preview on Interface Builder, as described in this question and many others.

However, I can not get Interface Builder to refresh (render) my view.

As is usual, I am placing a stock UIView from the object library into the view heirarchy in Interface Builder, and changing its class to my own in the Identity Inspector. The field "Desginables" (right under "Inherit Module from Target") appears as "Up to date".

However, the internal layout of my custom view is not previewed. (it contains a textfield, a label, and a custom background color).


Choosing Editor > Refresh All Views from the main menu triggers a build, and a momentary change to "Designables Updating", but when the build finishes, my custom view remains blank.

I tried creating a new, minimal project (from the Sinlge View Application project template) and transplanted my .xib and custom class source file, untouched. Rest assured, when placed inside a xib or storyboard, they are previewed as expected.


I know this is perhaps a long shot, but is this a known issue of Xcode with large projects?

Or is perhaps some other setting I should look for in my existing project that may be interfering with the rendering of designables?

Nicolas Miari
  • 16,006
  • 8
  • 81
  • 189
  • I've recently run into this issue. Restarting Xcode seemed to be the only way to fix it. – Mike Taverne Feb 16 '18 at 06:02
  • I restarted Xcode... now I get "Designables: Build Failed", and "Refresh all views" is grayed out... – Nicolas Miari Feb 16 '18 at 06:13
  • If you build, does the compiler show any errors? – Mike Taverne Feb 16 '18 at 06:16
  • I noticed a stray warning about a custom class not being found by IB and using UIView instead, but can't find it now. I deleted and re-entered the custom class name, and deleted and re-added the view to the xib... – Nicolas Miari Feb 16 '18 at 06:19
  • Now I've restarted Xcode again. "Refresh All Views" is enabled again, designables are "Updating". I'm afraid this whole feature of IB just isn't ready for large projects. – Nicolas Miari Feb 16 '18 at 06:21
  • 2
    ...aaand "Up to Date". But still not showing. I'll just see if at least my view works at runtime. Thank you anyway! – Nicolas Miari Feb 16 '18 at 06:22
  • Don’t leave “Refresh All Views” enabled because it will kill performance of Xcode. You can manually refresh views when needed. I have a large project and IB works well but not perfectly. Keep your storyboards small. You can create multiple ones and reference one from another. That may help. – Mike Taverne Feb 16 '18 at 06:26
  • From the SO post you referenced, it said this: “Do not set the custom class of the view on the xib. Only the File Owner!“ – Mike Taverne Feb 16 '18 at 06:32
  • 1
    @MikeTaverne I am doing exactly that. In the **custom** xib (where my custom view's layout is defined), I set File Owner (_not_ Class). In the _other_ xib (or storyboard - the one that loads the instance), however, I drop a stock UIView and change its **class** to my own. – Nicolas Miari Feb 16 '18 at 06:40
  • 1
    My experience of this is that it's usually caused by an unrelated target not building successfully. It seems that all targets in the workspace need to build successfully, including ones that have nothing to do with the storyboard and even ones that aren't iOS. – Nestor Jan 29 '19 at 11:22
  • @Nestor Thank you. It’s been a while now, but I’ll watch out for that from now on! – Nicolas Miari Jan 29 '19 at 12:05

0 Answers0