You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
You have to handle @objc (and other attributes) requiring a Foundation import
extensions on TimeInterval don't find definition because definition is NSTimeInterval. I think the tool would need to understand apinotes to handle this case.
Some things come from places you might not expect, and that can be ok. SwiftLint provides a way to map imports. When we were using that we used this config:
unused_import:
require_explicit_imports: truealways_keep_imports:
- AVFoundation # Never translate to AVFAudio, which is only available in 14.5+allowed_transitive_imports:
- module: AVFoundationallowed_transitive_imports:
- AVFAudio
- module: Foundationallowed_transitive_imports:
- CoreFoundation
- Darwin
- ObjectiveC
- module: CoreMediaallowed_transitive_imports:
- _SwiftCoreMediaOverlayShims
- module: GoogleMapsallowed_transitive_imports:
- GoogleMapsBase
- module: GoogleNavigationallowed_transitive_imports:
- GoogleMaps
- module: UIKitallowed_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.
Some things you might want to allow shadowing of, like GoogleMapsBase vs GoogleMaps in the example config above, where that framework is distributed as 3 separate frameworks to avoid GitHub's file size limit, but realistically you likely want users to only ever import GoogleMaps, so I think this being user configurable is required.
There are some other cases I haven't debugged enough that cause some issues as well, but this is a sense of the work needed
The text was updated successfully, but these errors were encountered:
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:
@objc
(and other attributes) requiring a Foundation importTimeInterval
don't find definition because definition isNSTimeInterval
. I think the tool would need to understand apinotes to handle this case.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.GoogleMapsBase
vsGoogleMaps
in the example config above, where that framework is distributed as 3 separate frameworks to avoid GitHub's file size limit, but realistically you likely want users to only ever importGoogleMaps
, so I think this being user configurable is required.The text was updated successfully, but these errors were encountered: