Skip to content

Fix the Swift strict-concurrency warnings and gate them with an iOS CI build - #59

Merged
V3RON merged 2 commits into
mainfrom
claude/fix-swift-concurrency-warnings-57
Sep 16, 2026
Merged

V3RON merged 2 commits into
mainfrom
claude/fix-swift-concurrency-warnings-57

Conversation

@V3RON

@V3RON V3RON commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Closes #57. Prerequisite for #58 — merging this first lets #58 drop --allow-warnings on rebase, so trunk validation becomes a real gate rather than a rubber stamp.

The fixes

Redundant await — AppductClient+Session.swift:214. 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; this one was the outlier.

Main-actor isolation — AppductClientTypes.swift. isBackgrounded() read main-actor-isolated UIApplication.shared.applicationState from a nonisolated method. The manual Thread.isMainThread / DispatchQueue.main.sync hop already made this safe — MainActor.assumeIsolated states that guarantee to the compiler rather than only asserting it in a comment, which is exactly what -strict-concurrency=complete was objecting to.

The isMainThread branch is kept deliberately. It is load-bearing rather than an optimisation (sync onto the main queue from the main thread deadlocks), and it keeps assumeIsolated's own precondition satisfied on both paths — it traps if reached off the main actor. The only caller is AppductClient's actor init.

The part that matters more

CI has never compiled this code. test.yaml's swift build / swift test target the host — macOS — where #if canImport(UIKit) is false and UIKitAppductForegroundObserver is compiled out entirely. Both warnings were invisible to every existing job and would only ever have surfaced inside pod trunk push's validation, at release time.

So this adds an iOS-destination build:

xcodebuild -scheme AppductCore -destination 'generic/platform=iOS' \
  SWIFT_TREAT_WARNINGS_AS_ERRORS=YES build

generic/platform=iOS needs 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

  • Gate proven in both directions — BUILD FAILED on the unfixed sources, BUILD SUCCEEDED on the fixed ones
  • swift build + swift test on macOS — clean, 132 tests, 0 failures
  • xcodebuild -destination 'generic/platform=iOS' — clean, zero warnings
  • pod lib lint --platforms=ios passes with no --allow-warnings — the result this PR exists to produce
  • actionlint clean on the modified workflow

One flake worth recording: an earlier lint run returned a bare ERROR | xcodebuild: Returned an unsuccessful exit code with no underlying diagnostic, and did not reproduce on a clean re-run. Most likely contention with a concurrent xcodebuild on 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-warnings from publish-cocoapods, plus the paragraph about it in docs/CI.md.

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
V3RON merged commit 47a3c60 into main Sep 16, 2026
8 checks passed
@V3RON
V3RON deleted the claude/fix-swift-concurrency-warnings-57 branch September 16, 2026 07:27
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.
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.

Fix the three Swift warnings blocking a warning-free pod trunk push (drop --allow-warnings)

1 participant