Repository navigation
refactor(core): Swift 6 publish-readiness — MainActor metrics + atomic snapshot, 94% coverage - #5
Merged
Merged
Conversation
Isolate UIKit metric reads (UIScreen/UIApplication/UIDevice) to the main actor and publish an immutable Snapshot via swift-atomics ManagedAtomic; all scaling reads stay nonisolated. Delete the TTL caches, the Atomic wrapper, and os_unfair_lock. configure(with:)/refreshMetrics() are now @mainactor and refresh on orientation/scene notifications, fixing the stale-on-rotation bug. - Adopt Swift 6 language mode (tools 6.0, swiftLanguageModes [.v6]); drop the -strict-concurrency unsafe flag. - ScreenUtil is compiler-checked Sendable (no @unchecked). - Trim ScaleType to .width/.height/.text/.radius; drop deviceType from the configuration. - SwiftUI: replace deprecated .cornerRadius with clipShape; make @ScaledValue.wrappedValue nonisolated. - Document the breaking changes in CHANGELOG.
Dicky019
force-pushed
the
refactor/swift6-publish-readiness
branch
from
June 6, 2026 15:26
019f97a to
e3f875f
Compare
Cover numeric scaling on all types, CGGeometry helpers, FastScale, BatchScaler/batch APIs, ScreenDimensions, SwiftUI Font/Environment and property wrappers, and the snapshot refresh path. Rewrite the read-during-reconfigure race test as a fully main-actor-isolated async TaskGroup. Adjust existing tests for @mainactor configure and the trimmed ScaleType. Concurrent test blocks record validity and assert once afterward; XCTAssert is not safe to call from many threads (mutates shared XCTestCase state, which ThreadSanitizer flags in CI).
Run build/test/thread-sanitizer under Swift 6 and add a coverage job that fails when line coverage drops below 85%.
Dicky019
force-pushed
the
refactor/swift6-publish-readiness
branch
from
June 6, 2026 17:14
e3f875f to
0e824e7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Publish-readiness pass: full Swift 6 language mode, best-practice concurrency, and a ≥85% coverage gate. Pre-1.0, so public API was allowed to change.
Concurrency rearchitecture
UIScreen/UIApplication/UIDevice) are isolated to@MainActor; results are published as one immutableSnapshotvia swift-atomicsManagedAtomic. All scaling reads stay nonisolated (lock-free, race-free, snapshot-consistent).configure(with:)/refreshMetrics()are now@MainActor; they also refresh on orientation/scene notifications — fixes the stale-on-rotation bug.Atomicwrapper, and allos_unfair_lockusage. No hand-rolled locks remain.@unchecked Sendableretained with a documented invariant (only shared mutable state is the atomic).Swift 6 + API
swift-tools-version: 6.0,swiftLanguageModes: [.v6], dropped the-strict-concurrencyunsafe flag.ScaleTypetrimmed to.width/.height/.text/.radius;deviceTyperemoved from the config (nowScreenUtil.shared.deviceType).SwiftUI
.cornerRadius(_:)with.clipShape(RoundedRectangle(...)).@ScaledValue.wrappedValuemade nonisolated (consistent with@ScreenPercentage).Tests & CI
Conforms to the
swift-concurrencyandswiftui-expert-skillbest-practice guides.Test Plan
swift build— macOS ✅swift test— 113 tests, 0 failures ✅swift test --sanitize=thread— 0 data races ✅