SE-0362: Piecemeal adoption of future language improvements

SwiftPM targets should be able to specify the future language features they require. Extend the target part of the manifest to take a set of future features as strings, e.g.:

.target(name: "myPackage",
        futureFeatures: ["ConciseMagicFile", "ExistentialAny"])

Alternatively, should there be methods on SwiftSetting, with optional condition parameters?

extension SwiftSetting {

  public static func enableFutureFeature(
    _ name: String,
    _ condition: BuildSettingCondition? = nil
  ) -> SwiftSetting

  public static func enableExperimentalFeature(
    _ name: String,
    _ condition: BuildSettingCondition? = nil
  ) -> SwiftSetting
}

Contrived example:

.target(
  name: "MyTarget",
  swiftSettings: [
    .define("FLAG_ONE"),
    .define("FLAG_TWO"),
    .enableFutureFeature("BareSlashRegexLiterals"),
    .enableFutureFeature("ForwardTrailingClosures"),
    .enableFutureFeature("ConciseMagicFile", .when(platforms: [.macOS])),
    .enableFutureFeature("ExistentialAny", .when(configuration: .debug)),
  ]
)
3 Likes