I have a simple UIButton subclass that implements IBDesignable with an IBInspectable var:
@IBDesignable class Button:
What is causing this?
This error appears when two things happen:
@IBDesignable or @IBInspectable in your test target.How can I prevent this from happening?
Either:
@IBDesignable or @IBInspectable in your test target. (If you’re just testing a few isolated model files, they can remain members of your test target.)@testable import MyApp—see here for more details.) This is the best practice, allowing you to continue testing your designable/inspectable views as well as any model code in your app.How can I solve it once it's already happened?
The pesky thing with this error is that it doesn’t automatically go away once the problem has been solved, potentially because IB may be caching something as Gerd suggests in his answer.
What I’ve found is that once you’ve actually performed either of the two preventative measures I listed above, simply restarting Xcode (without modifying any code) should make the error go away.