Skip to content

Commit

Permalink
Enable SwiftConcurrency feature in new compilers (#11)
Browse files Browse the repository at this point in the history
# Enable SwiftConcurrency feature in new compilers

## ♻️ Current situation & Problem
This PR makes sure to enabled the `SwiftConcurrency` feature also with
Swift 6 compilers.
Further, we add SwiftLint if requested from the environment.

## ⚙️ Release Notes 
* Support SwiftConcurrency in Swift 6 compilers´
* Add SwiftLint build tool if `SPEZI_DEVELOPMENT_SWIFTLINT` environment
variable is set.

## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
Supereg authored Jun 26, 2024
1 parent 656f765 commit 3326fea
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
// SPDX-License-Identifier: MIT
//

import class Foundation.ProcessInfo
import PackageDescription


#if swift(<6)
let swiftConcurrency: SwiftSetting = .enableExperimentalFeature("SwiftConcurrency")
#else
let swiftConcurrency: SwiftSetting = .enableUpcomingFeature("SwiftConcurrency")
#endif


let package = Package(
name: "SpeziFoundation",
defaultLocalization: "en",
Expand All @@ -24,21 +32,45 @@ let package = Package(
products: [
.library(name: "SpeziFoundation", targets: ["SpeziFoundation"])
],
dependencies: swiftLintPackage(),
targets: [
.target(
name: "SpeziFoundation",
resources: [
.process("Resources")
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency")
]
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
),
.testTarget(
name: "SpeziFoundationTests",
dependencies: [
.target(name: "SpeziFoundation")
]
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
)
]
)


func swiftLintPlugin() -> [Target.PluginUsage] {
// Fully quit Xcode and open again with `open --env SPEZI_DEVELOPMENT_SWIFTLINT /Applications/Xcode.app`
if ProcessInfo.processInfo.environment["SPEZI_DEVELOPMENT_SWIFTLINT"] != nil {
[.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLint")]
} else {
[]
}
}

func swiftLintPackage() -> [PackageDescription.Package.Dependency] {
if ProcessInfo.processInfo.environment["SPEZI_DEVELOPMENT_SWIFTLINT"] != nil {
[.package(url: "https://github.com/realm/SwiftLint.git", .upToNextMinor(from: "0.55.1"))]
} else {
[]
}
}

0 comments on commit 3326fea

Please sign in to comment.