Required Deinit

Classes should have an explicit deinit method

  • Identifier: required_deinit
  • Enabled by default: No
  • Supports autocorrection: No
  • Kind: lint
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning

Non Triggering Examples

class Apple {
    deinit { }
}
enum Banana { }
protocol Cherry { }
struct Damson { }
class Outer {
    deinit { print("Deinit Outer") }
    class Inner {
        deinit { print("Deinit Inner") }
    }
}

Triggering Examples

class Apple { }
class Banana: NSObject, Equatable { }
class Cherry {
    // deinit { }
}
class Damson {
    func deinitialize() { }
}
class Outer {
    func hello() -> String { return "outer" }
    deinit { }
    class Inner {
        func hello() -> String { return "inner" }
    }
}
class Outer {
    func hello() -> String { return "outer" }
    class Inner {
        func hello() -> String { return "inner" }
        deinit { }
    }
}