Duplicate Imports

Imports should be unique

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

Non Triggering Examples

import A
import B
import C
import A.B
import A.C
@_implementationOnly import A
@_implementationOnly import B
@testable import A
@testable import B
#if DEBUG
    @testable import KsApi
#else
    import KsApi
#endif
import A // module
import B // module
#if TEST
func test() {
}
import Foo
@testable import struct Foo.Bar

Triggering Examples

@_implementationOnly import A
@_implementationOnly import A

@testable import A
@testable import A

@testable import Foo
import struct Foo.Bar
import A
#if DEBUG
    @testable import KsApi
#else
    import KsApi
#endif
import A

import A
import class A.Foo

import A
import enum A.Foo

import A
import func A.Foo

import A
import let A.Foo

import A
import protocol A.Foo

import A
import struct A.Foo

import A
import typealias A.Foo

import A
import var A.Foo

import A.B
import A.B.C

import Foundation
import Dispatch
import Foundation

import Foundation
import Foundation
import Foundation

import Foundation
import Foundation.NSString

import A.B.C
import A.B

import Foundation.NSString
import Foundation