XCode 9 issue. Failed to set user defined property in interface builder

480 views Asked by At

My issue is that settings a keypath and value in interface builder does not seem to be working in XCode 9. There is a work around where you make the variable inspectable.

I've created a sample project and details below.

I created a simple test class where I set properties given a path and a value, like so.

enter image description here

You'll see there are two strings being set, ignore backgroundColor that was a sanity check, key path "string" works but key path "string2" does not. "string" And "string2" differ in one way and that's in their declaration as shown here.

@IBInspectable var string: String = ""
var string2: String = ""

The result of all this is code is shown here.

enter image description here

I used to do this all the time in XCode 8, ios9 without issue, did I miss something with the update? I have a work around but the issue still vexes me.

1

There are 1 answers

0
Yogurt On BEST ANSWER
// mark the line as @objc
@objc var string: String

This was the answer given by dan in the comments.