Skip to content

Commit

Permalink
Move warning about strict concurrency into PlatformChecks.swift (#289)
Browse files Browse the repository at this point in the history
### Motivation

In #191 we enabled strict concurrency in CI. We also attempted to
include it conditionally as part of a local development flow. However,
the `#warning` (that strict concurrency was enabled) added to
Package.swift was firing unconditionally because it was, itself, behind
a _runtime_ conditional.

### Modifications

Now if `SWIFT_OPENAPI_STRICT_CONCURRENCY=true` then we will add a
`define` to the `swiftSettings` and we will move the `#warning` to the
existing `PlatformChecks.swift`.

### Result

Opening Xcode with `SWIFT_OPENAPI_STRICT_CONCURRENCY=true` will enable
strict concurrency warnings locally. Opening Xcode without this will no
longer produce a misleading warning.

### Test Plan

Tested locally.

Signed-off-by: Si Beaumont <[email protected]>
  • Loading branch information
simonjbeaumont authored Sep 21, 2023
1 parent 6a259ae commit 0de1799
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ swiftSettings.append(

// Strict concurrency is enabled in CI; use this environment variable to enable it locally.
if ProcessInfo.processInfo.environment["SWIFT_OPENAPI_STRICT_CONCURRENCY"].flatMap(Bool.init) ?? false {
#warning("Compiling with Strict Concurrency")
swiftSettings.append(contentsOf: [
.define("SWIFT_OPENAPI_STRICT_CONCURRENCY"),
.enableExperimentalFeature("StrictConcurrency"),
.unsafeFlags(["-warnings-as-errors"]),
])
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions Sources/_OpenAPIGeneratorCore/PlatformChecks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
#if !(os(macOS) || os(Linux))
#error("_OpenAPIGeneratorCore is only to be used by swift-openapi-generator itself—your target should not link this library or the command line tool directly.")
#endif

#if SWIFT_OPENAPI_STRICT_CONCURRENCY
#warning("Compiling with Strict Concurrency")
#endif

0 comments on commit 0de1799

Please sign in to comment.