Also if you don't have a parent class and if you have to implement init?(coder:) you can implement a global function as below to avoid string coding in every new class:
@inlinable
@inline(__always)
public func fatalErrorNotImplemented(
function: String = #function,
file: StaticString = #file,
line: UInt = #line
) -> Never {
fatalError(
function + " not implemented",
file: file,
line: line
)
}
Usage:
final class AnotherView: UIView {
let value: Any
init(config: Any) {
self.value = value
super.init(frame: .zero)
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalErrorNotImplemented() // No strings
}
}