IBDesignable Build Failed
I stumbled on this issue as well, and have two suggestions that might be helpful:
- In the "Report Navigator" (cmd-9) check the "Interface Builder" build log, it's a separate build from your normal project build, there could be useful error messages there instead of just "Build failed".
- The Interface Builder build is done for the Simulator, i.e. x86_64 architecture. Some parts of iOS (like Metal in my case) are not present on the simulator, resulting in build failures. I defined some classes and functions inside
#if targetEnvironment(simulator)
blocks to at least pass the build.
First Try: IBDesignable Build Failed
For me when I was hovering over the InterfaceBuilder
Designables: Build Failed
,
it was giving an error message saying something like
Cannot find any source files for the declaration or ...
So, I got it as a clue like that Xcode couldn't index my custom UIView
class file so what I did is I just quit Xcode and Restarted it and then it had indexed my custom Swift class file and InterfaceBuilder was able to find it properly.
First of all try it out and then go to other options!
It was failing because the variables of IBInspectable
are used in someone else's IBDesignable
class
The following steps resolved the issue:
- Rename the class
- Clean the project.
- Select storyboard, go to the Editor menu and do Refresh All Views or else select Automatic Refresh view; wait for build to be completed.