# Enabling strict-concurrency across entire package?

**URL:** <https://forums.swift.org/t/enabling-strict-concurrency-across-entire-package/65228>\
**Category:** Using Swift\
**Created:** [May 27, 2023, 8:42pm UTC](https://forums.swift.org/t/enabling-strict-concurrency-across-entire-package/65228 "2023-05-27T20:42:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [May 27, 2023, 8:42pm UTC](https://forums.swift.org/t/enabling-strict-concurrency-across-entire-package/65228/1 "2023-05-27T20:42:25Z")

</div>

with tools version 5.8, we can now turn on strict concurrency checking with

```swift
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]

```

but this needs to be added to _each_ target in the manifest. can this be applied to _all_ targets in the manifest at once?

---

<div class="post-metadata">

**Author:** ![filip-sakel](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/filip-sakel/32/8697_2.png) [@filip-sakel](https://forums.swift.org/u/filip-sakel)\
**Post date:** [May 27, 2023, 9:23pm UTC](https://forums.swift.org/t/enabling-strict-concurrency-across-entire-package/65228/2 "2023-05-27T21:23:21Z")

</div>

> [@taylorswift](#):
>
> `.enableUpcomingFeature("StrictConcurrency")`

Not sure if there's a better way but you can create your own extension:

```swift
// In `Package.swift`

extension Array where Element == Target {
    func strictConcurrency() -> [Target] {
        map {
            var copy = $0
            copy.swiftSettings = (copy.swiftSettings ?? [])
                + [.enableUpcomingFeature("StrictConcurrency")]
            return copy
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![SDGGiesbrecht](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sdggiesbrecht/32/4768_2.png) [@SDGGiesbrecht](https://forums.swift.org/u/SDGGiesbrecht)\
**Post date:** [May 27, 2023, 10:30pm UTC](https://forums.swift.org/t/enabling-strict-concurrency-across-entire-package/65228/3 "2023-05-27T22:30:26Z")

</div>

```swift
let package = Package(
  // ...
)

for target in package.targets {
  var swiftSettings = target.swiftSettings ?? []
  defer { target.swiftSettings = swiftSettings }

  swiftSettings.append(.enableUpcomingFeature("StrictConcurrency"))

  // And it easily composes with other global things:

  swiftSettings.append(
    .define(
      "APPLE_PLATFORM",
      .when(platforms: [.macOS, .tvOS, .iOS, .watchOS])
    )
  )

  #if os(Windows)
    target.plugins = nil
    swiftSettings.append(
      .define("PLUGINS_UNAVAILABLE")
    )
  #endif
}

```

---

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [May 27, 2023, 10:47pm UTC](https://forums.swift.org/t/enabling-strict-concurrency-across-entire-package/65228/4 "2023-05-27T22:47:52Z")

</div>

wow! i always forget how much we can do in the manifests… if only we could share these scripts across multiple packages…
