Last active
April 22, 2025 10:46
-
-
Save ole/c0f4de915a483edb5e6df5f1ad677fb5 to your computer and use it in GitHub Desktop.
SwiftPM Package.swift with upcoming features enabled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// swift-tools-version: 6.0 | |
// The swift-tools-version declares the minimum version of Swift required to build this package. | |
import PackageDescription | |
let package = Package( | |
name: "MyPackage", | |
products: [ | |
.library(name: "MyLibrary", targets: ["MyLibrary"]), | |
], | |
dependencies: [ | |
// Dependencies declare other packages that this package depends on. | |
// .package(url: /* package url */, from: "1.0.0"), | |
], | |
targets: [ | |
.target(name: "MyLibrary", dependencies: []), | |
.testTarget(name: "MyLibraryTests", dependencies: ["MyLibrary"]), | |
] | |
) | |
// List of upcoming feature flags we want to enable in all targets. | |
// Generally, we want to adopt new features as soon as they're available, i.e. this list should include | |
// all upcoming features that aren't enabled by default in our language mode. | |
// | |
// For listing all upcoming features for a given Swift language mode, see my `swift-list-features.sh` script: | |
// https://gist.github.com/ole/478874632fca61869928a0cc0a956972 | |
let upcomingFeaturesPostSwift6: [SwiftSetting] = [ | |
// SE-0335: Introduce existential any | |
// <https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md> | |
.enableUpcomingFeature("ExistentialAny"), | |
// SE-0409: Access-level modifiers on import declarations | |
// <https://github.com/swiftlang/swift-evolution/blob/main/proposals/0409-access-level-on-imports.md> | |
.enableUpcomingFeature("InternalImportsByDefault"), | |
// SE-0444: Member import visibility | |
// <https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md> | |
.enableUpcomingFeature("MemberImportVisibility"), | |
] | |
// Enable upcoming features on all targets. | |
for target in package.targets { | |
// Should we also exclude target.type == .system? | |
guard target.type != .binary else { | |
continue | |
} | |
var swiftSettings = target.swiftSettings ?? [] | |
swiftSettings.append(contentsOf: upcomingFeaturesPostSwift6) | |
target.swiftSettings = swiftSettings | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment