MobileNativeFoundation / swift-index-store

Library to read from Swift / clang source code indexes
Apache License 2.0
137 stars 11 forks source link

Handle removing system imports #25

Open keith opened 1 year ago

keith commented 1 year ago

Right now only your own imports are correctly handled. System imports bring a new set of issues. Here are a few I hit while working on this:

unused_import:
  require_explicit_imports: true
  always_keep_imports:
    - AVFoundation # Never translate to AVFAudio, which is only available in 14.5+
  allowed_transitive_imports:
    - module: AVFoundation
      allowed_transitive_imports:
        - AVFAudio
    - module: Foundation
      allowed_transitive_imports:
        - CoreFoundation
        - Darwin
        - ObjectiveC
    - module: CoreMedia
      allowed_transitive_imports:
        - _SwiftCoreMediaOverlayShims
    - module: GoogleMaps
      allowed_transitive_imports:
        - GoogleMapsBase
    - module: GoogleNavigation
      allowed_transitive_imports:
        - GoogleMaps
    - module: UIKit
      allowed_transitive_imports:
        - CoreFoundation
        - CoreGraphics
        - CoreText
        - Darwin
        - ObjectiveC
        - QuartzCore

But this can depend on how strict you want to be. Besides AVFoundation / AVFAudio which you can only fix if you have a high deployment target.