Repository navigation
Fix the Swift strict-concurrency warnings and gate them with an iOS CI build - #59
Merged
Merged
Conversation
Closes #57. Two fixes in the Swift core: - `AppductClient+Session.swift` dropped a redundant `await`. `AppductClient` is an actor and `settlePendingAttempt` is a synchronous, `@discardableResult` method on it, so the `Task { }` inside `performHandshake` inherits the actor's isolation and there is no hop to suspend on. Every other call site already omits it. - `UIKitAppductForegroundObserver.isBackgrounded()` read main-actor-isolated `UIApplication.shared.applicationState` from a nonisolated method. The manual `Thread.isMainThread` / `DispatchQueue.main.sync` hop already made that safe; `MainActor.assumeIsolated` states the guarantee to the compiler instead of only asserting it in a comment. The `isMainThread` branch is kept -- it is load-bearing, since `sync` onto the main queue from the main thread deadlocks, and it also keeps `assumeIsolated`'s precondition satisfied on both paths. The more durable half is the new CI step. `swift build` targets the host -- macOS -- where `#if canImport(UIKit)` is false and the observer is compiled out entirely, so no job had ever compiled that code for iOS. Both warnings were therefore invisible to CI and would only ever have surfaced during `pod trunk push`'s validation at release time. `xcodebuild -destination 'generic/platform=iOS'` with SWIFT_TREAT_WARNINGS_AS_ERRORS=YES closes that gap, so a new warning fails on the PR that introduces it rather than blocking a release weeks later. Verified: the gate fails on the unfixed sources and passes on the fixed ones; `swift build`/`swift test` clean on macOS (132 tests); and `pod lib lint --platforms=ios` now passes *without* `--allow-warnings`.
V3RON
added a commit
that referenced
this pull request
Sep 16, 2026
#59 fixed the three strict-concurrency warnings that forced the flag, and added an iOS-destination build to test.yaml with warnings-as-errors. With that gate in place a new warning fails on the PR that introduces it, so trunk validation can be strict here without turning a release into the first place anyone finds out. Verified: `pod lib lint AppductCore.podspec --platforms=ios` passes on this branch with no --allow-warnings. Note the iOS gate does not cover tvOS, which the podspec also declares and trunk also validates.
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.
Closes #57. Prerequisite for #58 — merging this first lets #58 drop
--allow-warningson rebase, so trunk validation becomes a real gate rather than a rubber stamp.The fixes
Redundant
await—AppductClient+Session.swift:214.AppductClientis an actor andsettlePendingAttemptis a synchronous@discardableResultmethod on it, so theTask { }insideperformHandshakeinherits the actor's isolation and there is no hop to suspend on. Every other call site already omits it; this one was the outlier.Main-actor isolation —
AppductClientTypes.swift.isBackgrounded()read main-actor-isolatedUIApplication.shared.applicationStatefrom a nonisolated method. The manualThread.isMainThread/DispatchQueue.main.synchop already made this safe —MainActor.assumeIsolatedstates that guarantee to the compiler rather than only asserting it in a comment, which is exactly what-strict-concurrency=completewas objecting to.The
isMainThreadbranch is kept deliberately. It is load-bearing rather than an optimisation (synconto the main queue from the main thread deadlocks), and it keepsassumeIsolated's own precondition satisfied on both paths — it traps if reached off the main actor. The only caller isAppductClient's actor init.The part that matters more
CI has never compiled this code.
test.yaml'sswift build/swift testtarget the host — macOS — where#if canImport(UIKit)is false andUIKitAppductForegroundObserveris compiled out entirely. Both warnings were invisible to every existing job and would only ever have surfaced insidepod trunk push's validation, at release time.So this adds an iOS-destination build:
generic/platform=iOSneeds no booted simulator. Warnings-as-errors is the point: once #58 drops--allow-warnings, any new warning in these sources blocks a release, so it has to fail on the PR that introduces it instead.Verification
BUILD FAILEDon the unfixed sources,BUILD SUCCEEDEDon the fixed onesswift build+swift teston macOS — clean, 132 tests, 0 failuresxcodebuild -destination 'generic/platform=iOS'— clean, zero warningspod lib lint --platforms=iospasses with no--allow-warnings— the result this PR exists to produceactionlintclean on the modified workflowOne flake worth recording: an earlier lint run returned a bare
ERROR | xcodebuild: Returned an unsuccessful exit codewith no underlying diagnostic, and did not reproduce on a clean re-run. Most likely contention with a concurrentxcodebuildon the same machine. Noting it rather than claiming it is understood.tvOS is still unverified — no simulator runtime available locally. The new CI step covers iOS only; trunk validates tvOS too.
After this merges
Rebase #58 and drop
--allow-warningsfrompublish-cocoapods, plus the paragraph about it indocs/CI.md.