Skip to content

Adopt Swift 6 language mode for Domain target#98

Draft
tosh7 wants to merge 3 commits into
developfrom
feature/domain-swift6
Draft

Adopt Swift 6 language mode for Domain target#98
tosh7 wants to merge 3 commits into
developfrom
feature/domain-swift6

Conversation

@tosh7

@tosh7 tosh7 commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Enable Swift 6 language mode for the Domain framework (SWIFT_VERSION = 6.0, Debug + Release).
  • Make the Domain API layer Sendable so it compiles cleanly under strict concurrency.

Changes

  • ApiClient: stored properties made immutable (let) and the type conforms to Sendable. Removed the unused updateConfiguration mutator (the singleton was never reconfigured at runtime).
  • Value types marked Sendable: APIClientConfiguration, RetryPolicy, APIError, HTTPMethod, DeliveryCarrierType, UnifiedDeliveryStatus, UnifiedDeliveryInfo.
  • Cache layer: DeliveryCacheProtocol now requires Sendable.
    • DeliveryMemoryCache / DeliveryDiskCache: @unchecked Sendable (memory cache is NSLock-protected; disk cache relies on file IO).
    • DeliveryTieredCache: checked Sendable.

Open question / follow-up

  • The two @unchecked Sendable caches rely on manual guarantees rather than compiler-checked safety. If the deployment target allows iOS 18+, migrating the memory cache to Synchronization.Mutex (or an actor) would make it checked-safe. Left as a follow-up.

Test plan

  • Domain target builds under Swift 6 language mode
  • Full app build (app/widget/watch targets) on a real destination
  • Smoke test delivery tracking + cache behavior on simulator/device

tosh7 added 3 commits June 21, 2026 10:35
Set SWIFT_VERSION to 6.0 for the Domain framework (Debug and Release) to
enable Swift 6 language mode and strict concurrency checking on shared
business logic.
Adopt Sendable across the API layer so it compiles under Swift 6 language
mode without data-race warnings.

- ApiClient: make stored properties immutable (let) and conform to
  Sendable; remove the unused updateConfiguration mutator
- Mark value types Sendable: APIClientConfiguration, RetryPolicy,
  APIError, HTTPMethod, DeliveryCarrierType, UnifiedDeliveryStatus,
  UnifiedDeliveryInfo
- DeliveryCacheProtocol: require Sendable; conform the cache
  implementations (memory/disk use @unchecked Sendable backed by NSLock
  and stateless file IO, tiered cache is checked Sendable)
Move the cache implementations to compiler-checked Sendable instead of
manual @unchecked guarantees.

- DeliveryMemoryCache: store entries in a Mutex instead of a var dict
  guarded by NSLock
- DeliveryDiskCache: drop the non-Sendable stored FileManager/encoder/
  decoder and create them locally per call so the type is checked Sendable
- CacheEntry: add conditional Sendable conformance (where T: Sendable)
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.

1 participant