Misleading errors with @IBInspectable & @GKInspectable attributes

Update: I have made a pull request to make the message more accurate :)

Hello Swift Forums,

currently, as known @IBInspectable & @GKInspectable are only to be used as instance properties of class types, however, when incorrectly used as instance properties in another type, the error only instance properties can be declared @IBInspectable / @GKInspectable is blurted out

I believe the error message should be changed to reflect the attributes only being allowed to be used as class instance properties, say, only class instance properties can be declared @IBInspectable / @GKInspectable


Seems like a good enhancement bug at Issues · apple/swift · GitHub.

1 Like

If no disagreements are presented in this thread, I’ll instead open a pull request to change the error message today or tomorrow

1 Like

Unless the error message is specific to IBInspectable, there will probably need to be more consideration than just changing the message.

The error message is very well specific to IBInspectable and GKInspectable by looking at DiagnosticSema.def.


Opened pull request: Change message of `invalid_iboutlet` and `invalid_ibinspectable` to reflect accurate usage by SerenaKit · Pull Request #59198 · apple/swift · GitHub