Deployment Target

Availability checks or attributes shouldn’t be using older versions that are satisfied by the deployment target.

  • Identifier: deployment_target
  • Enabled by default: Yes
  • Supports autocorrection: No
  • Kind: lint
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning
    iOSApplicationExtension_deployment_target 7.0
    iOS_deployment_target 7.0
    macOSApplicationExtension_deployment_target 10.9
    macOS_deployment_target 10.9
    tvOSApplicationExtension_deployment_target 9.0
    tvOS_deployment_target 9.0
    watchOSApplicationExtension_deployment_target 1.0
    watchOS_deployment_target 1.0

Non Triggering Examples

@available(iOS 12.0, *)
class A {}
@available(iOSApplicationExtension 13.0, *)
class A {}
@available(watchOS 4.0, *)
class A {}
@available(watchOSApplicationExtension 4.0, *)
class A {}
@available(swift 3.0.2)
class A {}
class A {}
if #available(iOS 10.0, *) {}
if #available(iOS 10, *) {}
guard #available(iOS 12.0, *) else { return }
#if #unavailable(iOS 15.0) {}
#guard #unavailable(iOS 15.0) {} else { return }

Triggering Examples

@available(iOS 6.0, *)
class A {}
@available(iOSApplicationExtension 6.0, *)
class A {}
@available(iOS 7.0, *)
class A {}
@available(iOS 6, *)
class A {}
@available(iOS 6.0, macOS 10.12, *)
 class A {}
@available(macOS 10.12, iOS 6.0, *)
 class A {}
@available(macOS 10.7, *)
class A {}
@available(macOSApplicationExtension 10.7, *)
class A {}
@available(OSX 10.7, *)
class A {}
@available(watchOS 0.9, *)
class A {}
@available(watchOSApplicationExtension 0.9, *)
class A {}
@available(tvOS 8, *)
class A {}
@available(tvOSApplicationExtension 8, *)
class A {}
if #available(iOS 6.0, *) {}
if #available(iOS 6, *) {}
guard #available(iOS 6.0, *) else { return }
if #unavailable(iOS 7.0) {}
if #unavailable(iOS 6.9) {}
guard #unavailable(iOS 7.0) {} else { return }