IBDesignable Build Failed

谁说胖子不能爱 提交于 2019-12-03 04:48:47

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!

WholeCheese

In my case, the designables were working fine in my storyboard until I deleted a few labels in the view that were no longer necessary to my user interface.

There were no useful messages in either the build log or in the DiagnosticReport folder.

The fix for me was to delete the DerivedData folder (an Xcode "reboot") and rebuild the project. Magically, the storyboard is again showing my custom knobs! :-)

VishalPethani

It was failing because the variables of IBInspectable are used in someone else's IBDesignable class

The following steps resolved the issue:

  1. Rename the class
  2. Clean the project.
  3. Select storyboard, go to the Editor menu and do Refresh All Views or else select Automatic Refresh view; wait for build to be completed.

I stumbled on this issue as well, and have two suggestions that might be helpful:

  1. 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".
  2. 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.

I struggled with this too and then deleted projects derived data and restarted Xcode before it would work again. "Debug Selected Views" was always disabled and designable build was always showing as failed. App compiled and ran fine.

If your CustomClass is added in to the project as Reference files then this occurs. That is for example you can see Blue coloured folder in the Project Explorer, that are Reference folders. If you are copying the Classes into our project then make sure that 'Copy items if needed' is selected.

In my case, this was the issue.

Even with the first 2 steps fixed mine. 1. Set the Class to DesignableView. 2. Set the Module to 3. Clean the build. 4. Restart Xcode.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!