Valid IBInspectable
@IBInspectable should be applied to variables only, have its type explicit and be of a supported type
- Identifier:
valid_ibinspectable
- Enabled by default: Yes
- Supports autocorrection: No
- Kind: lint
- Analyzer rule: No
- Minimum Swift compiler version: 5.0.0
- Default configuration:
Key Value severity warning
Non Triggering Examples
class Foo {
@IBInspectable private var x: Int
}
class Foo {
@IBInspectable private var x: String?
}
class Foo {
@IBInspectable private var x: String!
}
class Foo {
@IBInspectable private var count: Int = 0
}
class Foo {
private var notInspectable = 0
}
class Foo {
private let notInspectable: Int
}
class Foo {
private let notInspectable: UInt8
}
extension Foo {
@IBInspectable var color: UIColor {
set {
self.bar.textColor = newValue
}
get {
return self.bar.textColor
}
}
}
class Foo {
@IBInspectable var borderColor: UIColor? = nil {
didSet {
updateAppearance()
}
}
}
Triggering Examples
class Foo {
@IBInspectable private ↓let count: Int
}
class Foo {
@IBInspectable private ↓var insets: UIEdgeInsets
}
class Foo {
@IBInspectable private ↓var count = 0
}
class Foo {
@IBInspectable private ↓var count: Int?
}
class Foo {
@IBInspectable private ↓var count: Int!
}
class Foo {
@IBInspectable private ↓var count: Optional<Int>
}
class Foo {
@IBInspectable private ↓var x: Optional<String>
}