Skip to content

Replace UIKit helpers that came from the Zendesk SDK - #26435

Open
jkmassel wants to merge 1 commit into
trunkfrom
jkmassel/replace-zendesk-sdk-helpers
Open

jkmassel wants to merge 1 commit into
trunkfrom
jkmassel/replace-zendesk-sdk-helpers

Conversation

@jkmassel

Copy link
Copy Markdown
Contributor

Replaces UIView, UIColor and String helpers that 18 files were getting from the Zendesk SDK without importing it. Nothing changes on screen. Extracted from #26434, which removes the SDK.

Summary

  • Zendesk's modules declare public extensions on UIView, UIColor and String, so any file in the app can call them without an import. These 18 files do, and would stop compiling once the SDK is removed.
  • Each call is replaced with what the helper does, using UIKit or a helper the app already has.
  • The action sheet's button badge used two of the helpers. No caller ever set a badge, so it is removed.

Changes

SDK helper Replacement
safeLeadingAnchor, safeTrailingAnchor, safeTopAnchor, safeBottomAnchor, safeRightAnchor the same anchor on safeAreaLayoutGuide
constrainToSuperViewEdges() pinSubviewToAllEdges(_:)
constrain(size:) width and height anchor constraints
constrain(attribute:toView:relatedBy:constant:) leadingAnchor.constraint(greaterThanOrEqualTo:)
UIColor.colorFromHex("F6F7F7") UIColor(fromHex: 0xF6F7F7)
String.isEqual(to:) ==

The three constrain… helpers also set translatesAutoresizingMaskIntoConstraints = false. The view at each of those call sites already sets it.

Test plan

Simulator checks ran on an iPhone 18 Pro, iOS 27.2, with Debug builds.

  • Layout and colours are unchanged. A temporary launch hook (not in the diff) laid out the changed views with uneven safe-area insets and wrote out every subview's frame and background colour. A trunk build and this branch produce byte-identical output. With one replacement broken on purpose, the output differed. The hook covers 11 of the 18 files, listed below.
  • Each safe…Anchor helper returns the matching safeAreaLayoutGuide anchor (probe output below), so that swap is the same expression. It is the only change in six view controllers that need a site to create. Two of those were also opened in Jetpack with a WordPress.com account: My Site's empty state and the Notifications filter header render correctly.
  • Sign-in screen, WordPress app: the background measures #F6F7F7, the value in the code.
  • No uses left: git grep finds none of the helper names in the repo.
  • Builds: the Jetpack and WordPress schemes build.
  • Not done: the Reader scheme. It fails on trunk too (cannot find type 'PostHelper' in scope), and CI skips it for that reason. Pre-existing.
  • Unit tests: six suites that cover the changed files pass: Executed 50 tests, with 0 failures and Test run with 8 tests in 1 suite passed. The suites are listed below.
  • SwiftLint reports nothing on the 18 files.
What the hook covers, and the six files it doesn't

Compared by the hook:

  • DashboardPageCreationCell, expanded and compact
  • ReferrerDetailsCell, ReferrerDetailsHeaderCell and ReferrerDetailsSpamActionCell
  • GutenGhostView
  • JetpackOverlayView
  • a notice presented by NoticeAnimator
  • ActionSheetViewController with three buttons
  • DomainCreditRedemptionSuccessViewController
  • GutenbergSuggestionsViewController
  • the three colours in SplashPrologueStyleGuide
  • String.isEqual(to:) against == for five pairs of strings, which is the change in BooleanUserDefaultsDebugViewModel

Not built by the hook, because each needs a site: MySiteViewController, NotificationsViewController, GutenbergViewController, PreviewWebKitViewController, SiteStatsInsightsDetailsTableViewController and BloggingRemindersFlowSettingsViewController. Their only change is the safe…Anchor swap.

Unit test suites run, all in WordPressTest: BooleanUserDefaultsDebugViewModelTests, NotificationsViewControllerTests, PreviewWebKitViewControllerTests, ReferrerDetailsViewModelTests, SiteStatsInsightsDetailsViewModelTests and NoticePresenterLayoutTests.

What each helper does, printed by a probe linked against CommonUISDK 9.0.2
safeLeadingAnchor: other.leading == view.safeAreaLayoutGuide.leading * 1.0 + 0.0 @1000.0 active=false
safeTrailingAnchor: other.trailing == view.safeAreaLayoutGuide.trailing * 1.0 + 0.0 @1000.0 active=false
safeLeftAnchor: other.left == view.safeAreaLayoutGuide.left * 1.0 + 0.0 @1000.0 active=false
safeRightAnchor: other.right == view.safeAreaLayoutGuide.right * 1.0 + 0.0 @1000.0 active=false
safeTopAnchor: other.top == view.safeAreaLayoutGuide.top * 1.0 + 0.0 @1000.0 active=false
safeBottomAnchor: other.bottom == view.safeAreaLayoutGuide.bottom * 1.0 + 0.0 @1000.0 active=false
constrainToSuperViewEdges: tAMIC before=true
constrainToSuperViewEdges: tAMIC after=false returned=4 superviewConstraintsAdded=4
  edge: edgesView.leading == superview.leading * 1.0 + 0.0 @1000.0 active=true
  edge: edgesView.trailing == superview.trailing * 1.0 + 0.0 @1000.0 active=true
  edge: edgesView.top == superview.top * 1.0 + 0.0 @1000.0 active=true
  edge: edgesView.bottom == superview.bottom * 1.0 + 0.0 @1000.0 active=true
constrain(size:): tAMIC before=true
constrain(size:): tAMIC after=false returned=2 ownConstraints=2
  size: sizeView.height == nil.notAnAttribute * 1.0 + 20.0 @1000.0 active=true
  size: sizeView.width == nil.notAnAttribute * 1.0 + 10.0 @1000.0 active=true
constrain(attribute:toView:): tAMIC before=true
constrain(attribute:toView:): tAMIC after=false superviewConstraintsAdded=1
  attr: attrView.leading >= superview.leading * 1.0 + 16.0 @1000.0 active=true
colorFromHex(F6F7F7): r=246 g=247 b=247 a=1.0 space=kCGColorSpaceExtendedSRGB equalsOurs=true cgEqual=true
colorFromHex(2C3338): r=44 g=51 b=56 a=1.0 space=kCGColorSpaceExtendedSRGB equalsOurs=true cgEqual=true
colorFromHex(101517): r=16 g=21 b=23 a=1.0 space=kCGColorSpaceExtendedSRGB equalsOurs=true cgEqual=true
colorFromHex(BBE0FA): r=187 g=224 b=250 a=1.0 space=kCGColorSpaceExtendedSRGB equalsOurs=true cgEqual=true
colorFromHex(e9eff3): r=233 g=239 b=243 a=1.0 space=kCGColorSpaceExtendedSRGB equalsOurs=true cgEqual=true
colorFromHex(2e2e2e): r=46 g=46 b=46 a=1.0 space=kCGColorSpaceExtendedSRGB equalsOurs=true cgEqual=true

tAMIC is translatesAutoresizingMaskIntoConstraints. equalsOurs compares against UIColor(red:green:blue:alpha:) built from the same hex value, which is what UIColor(fromHex:) does.

Eighteen files used `UIView`, `UIColor` and `String` extensions that
the Zendesk SDK declares publicly: the `safe…Anchor` properties, the
`constrain…` methods, `UIColor.colorFromHex` and `String.isEqual(to:)`.
None of these files import Zendesk. They compiled because other files
in the app module do, so they would stop compiling once the SDK is
removed.

Each use is replaced with the UIKit equivalent, matching what the SDK's
helper does. The action sheet's button badge used two of the helpers
and no caller ever set it, so the badge is removed.
@jkmassel jkmassel added this to the 27.6 milestone Nov 21, 2026
@jkmassel jkmassel self-assigned this Nov 21, 2026
@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.

Generated by 🚫 Danger

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants