Fix CI: ObjC imports, Swift concurrency, macOS platform#3
Conversation
Co-authored-by: dustturtle <2305214+dustturtle@users.noreply.github.com>
Co-authored-by: dustturtle <2305214+dustturtle@users.noreply.github.com>
Co-authored-by: dustturtle <2305214+dustturtle@users.noreply.github.com>
Co-authored-by: dustturtle <2305214+dustturtle@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes CI failures related to SwiftPM ObjC header import resolution, Swift strict concurrency diagnostics, and missing macOS platform declaration.
Changes:
- Switched Objective-C header imports (in tests and public headers) from framework-style
<Module/Header.h>to quoted"Header.h"for SwiftPM builds. - Refactored
RealReachability.check()to avoidawaitin an autoclosure (from??) by using an explicitif/else. - Updated
ICMPPingerto prevent multiplecontinuation.resume(...)calls via a locked resume-state helper; added.macOS(.v10_15)toPackage.swift.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/RealReachability2ObjCTests/RRReachabilityTests.m | Updates ObjC import style for SwiftPM header layout. |
| Tests/RealReachability2ObjCTests/RRReachabilityIntegrationTests.m | Updates ObjC import style for SwiftPM header layout. |
| Sources/RealReachability2ObjC/include/RealReachability2ObjC.h | Switches umbrella header to quoted imports for SwiftPM. |
| Sources/RealReachability2ObjC/include/RRReachability.h | Switches dependent header import to quoted form for SwiftPM. |
| Sources/RealReachability2/RealReachability.swift | Avoids await in an autoclosure by using explicit control flow. |
| Sources/RealReachability2/Prober/ICMPPinger.swift | Introduces a lock-protected resume-state to satisfy strict concurrency and prevent double-resume. |
| Package.swift | Declares macOS 10.15 platform support to match CI/build availability requirements. |
| .gitignore | Ignores CodeQL detected source root file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| final class ResumeState { | ||
| private let lock = NSLock() | ||
| private var _isResumed = false | ||
|
|
||
| func tryResume() -> Bool { | ||
| lock.lock() |
There was a problem hiding this comment.
ResumeState is captured by DispatchWorkItem and NWConnection.stateUpdateHandler closures, which are @Sendable under Swift strict concurrency. As written, ResumeState is a non-Sendable class (contains NSLock), so this can still fail compilation with “capture of non-Sendable type in a @sendable closure”. Make ResumeState conform to Sendable (likely @unchecked Sendable given the internal locking), or replace it with a Sendable atomic/critical-state primitive.
CI failing on all jobs due to SPM import resolution, Swift strict concurrency violations, and missing macOS platform declaration.
ObjC header imports
SPM doesn't create framework directory structures. Changed to quoted imports:
Swift strict concurrency
ICMPPinger.swiftcaptured mutablevar isResumedin concurrent closures. Replaced with thread-safe wrapper:Swift await in autoclosure
RealReachability.swiftusedawaitwith??operator—right-hand side evaluates in autoclosure whereawaitis disallowed. Refactored to explicit if-else.macOS platform
Added
.macOS(.v10_15)toPackage.swift. CI runs on macOS; without this, availability errors forNWConnection,AsyncStream, etc.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.