Skip to content

fix: avoid Foundation's back-deployed Date comparison operators - #575

Merged
tanderson-ld merged 1 commit into
v11from
fix/date-backdeployed-comparison
Nov 23, 2026
Merged

tanderson-ld merged 1 commit into
v11from
fix/date-backdeployed-comparison

Conversation

@tanderson-ld

@tanderson-ld tanderson-ld commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replaces the one Date <= Date comparison in the SDK (FeatureFlag.shouldCreateDebugEvents) with a comparison of the two dates' timeIntervalSinceReferenceDate values. Behavior is unchanged. The SDK no longer references Foundation's back-deployed Date <= operator, which crashes on some iOS 27.2 beta builds.

Reported through customer support: an App Store app built with Xcode 27.2 crashed on 183 devices in two weeks with a jump to address 0x0 inside static Date.<= infix, called from FeatureFlag.shouldCreateDebugEvents via LDClient.stringVariation.

Root cause (Apple, not the SDK)

  • The Xcode 27.2 SDKs declare Foundation's Date <= and Date >= as @backDeployed(before: iOS 27.2). Apple added the operators to fix NaN handling: swift-foundation #2223, back-deployed on the release branch in swift-foundation #2230.
  • An app built with that SDK weak-imports the OS symbol and calls it whenever the device reports 27.2 or later.
  • iOS 27.2 developer beta 1 (24B5084k) and beta 2 (24B5089g) shipped a Foundation that did not export the symbol, so the call lands at address 0. Foundation gained the exports in beta 3 (24B5099f) and every later build, confirmed from Apple's own binaries in the ipsw-diffs Foundation diff.
  • Builds made with Xcode 27.1 or earlier inline the operator and cannot hit this. The same crash was reported against other libraries, for example swift-institute/Issues #140 and urbanairship/ios-library #467.

This comparison has been in the SDK unchanged since 2022 and is the only <= or >= between two Dates in the codebase.

Why this is equivalent

Apple's new operator is implemented as lhs.timeIntervalSinceReferenceDate <= rhs.timeIntervalSinceReferenceDate (Date.swift at the shipped commit, line 202), and timeIntervalSinceReferenceDate is a direct read of the stored Double. The pre-27.2 behavior was the standard library's Comparable default, !(rhs < lhs), over the same Double. The two differ only for NaN, which no date in this SDK can be. This change matches both.

Testing

Done:

  • swift build passes.
  • FeatureFlagSpec on an iPhone 16 simulator (iOS 18.6): 17 tests, 0 failures, including testShouldCreateDebugEvents.
  • SwiftLint clean.

In progress, will be posted here when complete:

  • Reproduce the crash on an iOS 27.2 beta 2 (24B5089g) simulator with the SDK built by Xcode 27.2 on v11 without this change, then show it passes with this change.
  • nm -m on the built framework: the weak import of $s10Foundation4DateV2leoiySbAC_ACtFZ is present before this change and absent after it.

Note

Overview
Fixes crashes on some iOS 27.2 beta devices when apps are built with Xcode 27.2: FeatureFlag.shouldCreateDebugEvents no longer calls Foundation’s back-deployed Date <= operator (which can resolve to a null symbol and jump to 0x0 on certain 27.2 betas).

The method now compares timeIntervalSinceReferenceDate on the two dates instead, preserving the same debug-event gating logic used from stringVariation / event reporting. Inline comments document that this is a platform/SDK linkage workaround, not a behavioral SDK change.

Reviewed by Cursor Bugbot for commit 0ce78ac. Bugbot is set up for automated code reviews on this repo. Configure here.

The Xcode 27.2 SDKs declare Foundation's `Date <=` and `Date >=` as
back-deployed. Early iOS 27.2 beta builds shipped a Foundation that did
not export those symbols, so any app built with that SDK crashed on a
null call when the SDK compared two Dates while deciding whether to
record debug events for a flag evaluation.

Compare the dates' time intervals directly instead. This is the same
expression Apple's new operator uses, so behavior is unchanged, and the
SDK no longer references the back-deployed symbol at all.
@tanderson-ld
tanderson-ld requested a review from a team as a code owner November 23, 2026 17:20
@cursor cursor Bot added the risk:low label Nov 23, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: low. Approved. Cursor Bugbot completed with no findings, and SDK approval policy Rules 1–3 all pass (not a release PR, allowed author, no GitHub Actions workflow changes).

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: low.

Automated risk review (dry run): Low

This PR would be automatically approved.

Why: The change is a one-function workaround in FeatureFlag.swift that compares timeIntervalSinceReferenceDate instead of using Foundation’s back-deployed Date <= operator, with existing FeatureFlagSpec coverage and no unresolved Bugbot findings.

If you disagree with this review, share this PR in #feedback-agent-approvals or submit a changes-requested review explaining why.

Open in Web View Automation 

Sent by Cursor Approval Agent: Dry-Run PR Approver

@tanderson-ld
tanderson-ld merged commit 1e18137 into v11 Nov 23, 2026
22 checks passed
@tanderson-ld
tanderson-ld deleted the fix/date-backdeployed-comparison branch November 23, 2026 17:33
tanderson-ld pushed a commit that referenced this pull request Nov 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[11.8.1](11.8.0...11.8.1)
(2026-11-23)


### Bug Fixes

* avoid Foundation's back-deployed Date comparison operators
([#575](#575))
([1e18137](1e18137))
* Record no variation and a WRONG_TYPE reason in events when a typed
evaluation has the wrong type
([#554](#554))
([d76e12e](d76e12e))
* Start the primary environment first, then secondary environments by
name ([#572](#572))
([30856c4](30856c4))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> **Release 11.8.1** bumps the SDK version from `11.8.0` to `11.8.1`
across packaging and metadata (Release Please manifest,
`LaunchDarkly.podspec`, Xcode `MARKETING_VERSION` / dylib versions,
`ReportingConsts.sdkVersion`, and README SPM pin).
> 
> The changelog for this patch documents three **bug fixes** shipped in
the release:
> 
> **Debug events on newer Apple SDKs:**
`FeatureFlag.shouldCreateDebugEvents` no longer compares `Date` values
with `<=` / `>=`. It uses `timeIntervalSinceReferenceDate` instead,
avoiding crashes when Foundation’s back-deployed Date operators are
missing on some iOS 27.2 beta builds.
> 
> **Typed evaluation analytics:** When a flag value cannot be decoded to
the requested type, evaluations now emit **`WRONG_TYPE`** with **no
variation index** in both the returned detail and recorded flag events
(via `withEvaluationResult(variation: nil, …)`).
> 
> **Multi-environment startup order:** `LDClient.start` initializes the
**primary** environment first, then **secondary** environments in
**stable alphabetical order by name**, so client creation and plugin
registration are deterministic across launches.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
4ad6acb. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: LaunchDarklyReleaseBot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants