Skip to content

Remove unnecessary UIKit imports - #25812

Draft
jkmassel wants to merge 1 commit into
trunkfrom
jkmassel/remove-unused-uikit-imports
Draft

Remove unnecessary UIKit imports#25812
jkmassel wants to merge 1 commit into
trunkfrom
jkmassel/remove-unused-uikit-imports

Conversation

@jkmassel

Copy link
Copy Markdown
Contributor

Removes import UIKit from files that reference no UIKit symbol — a follow-up to the cross-platform module split in #25344, where a stray UIKit import is what keeps a file (or an entire module) from compiling on platforms without UIKit.

Summary

  • 56 files; the repo-wide import UIKit count drops from 933 → 877.
  • Imports only — no behavior change.
  • Swept WordPress/, Modules/, Sources/, and Tests/. Every candidate was found by a heuristic pass (no UI* identifier, no UIKit-only NS* type, no UIKit extension-on-Foundation call) and then read individually to confirm.

Changes

Action Files Rationale
import UIKitimport Foundation 42 The file uses Foundation types (URL, NSCoder, NSLocalizedString, SortDescriptor, HTTPCookieStorage, …) that UIKit was only re-exporting
import UIKit removed 13 Foundation is already imported, or the file uses only SwiftUI / CoreLocation / the standard library
import UIKitimport QuartzCore 1 CATransaction+Extension.swiftCATransaction is Core Animation, not UIKit; a plain Foundation swap would not compile

UIKit re-exports Foundation, so the Foundation swaps are load-bearing — deleting the import outright would break any file leaning on it for URL/NSCoder/etc. SwiftUI, XCTest, CoreLocation, and WordPressData do not reliably re-export Foundation.

Test plan

  • xcodebuild buildWordPress scheme, iOS Simulator → BUILD SUCCEEDED, 0 errors (all 50 app/module source files)
  • xcodebuild build-for-testingWordPressUnitTests plan → TEST BUILD SUCCEEDED, 0 errors (the 6 test files, across the WordPressTest, WordPressKitTests, and AsyncImageKitTests targets)
  • CI green

Related

Sweep files that import UIKit but reference no UIKit symbol. Where the
import only provided Foundation via re-export, switch to `import
Foundation`; CATransaction+Extension moves to `import QuartzCore` since
CATransaction is Core Animation. Imports only, no behavior change.

Follow-up to #25344.
@dangermattic

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number33316
VersionPR #25812
Bundle IDorg.wordpress.alpha
Commitdf2edc9
Installation URL7m4sfd64mp210
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number33316
VersionPR #25812
Bundle IDcom.jetpack.alpha
Commitdf2edc9
Installation URL7g5un0vrq5k80
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants