Using Swift experimental with generated projects

Experimental Swift features usually come with an interface in the Package DSL, a build setting, and a build setting (for Xcode projects) to enable them.

If you are using Tuist generated projects to make your modular projects more manageable, you might wonder how to enable them. Since they are Xcode projects under the hood, you have to use build settings as described by Hasan:

import ProjectDescription

func baseSettings() -> SettingsDictionary {
  var settings: SettingsDictionary = [:]
  settings["SWIFT_VERSION"] = "6"
  settings["_EXPERIMENTAL_SWIFT_EXPLICIT_MODULES"] = "true"
  settings["SWIFT_STRICT_CONCURRENCY"] = "complete"

  return settings
}

let project = Project(
  name: "pinkponk",
  targets: [
    .target(
      name: "pinkponk",
      destinations: .macOS,
      ......
       settings: Settings.settings(
        base: baseSettings())
    ), ....

The build setting is usually documented in the blog post announcing the feature or in the feature’s documentation. For example, complete concurrency checking mentions the -strict-concurrency=complete compiler flag, which can be passed to SwiftPM with -Xswiftc -strict-concurrency=complete, the manifest API, .enableExperimentalFeature("StrictConcurrency"), and the build setting, SWIFT_STRICT_CONCURRENCY = complete;.

1 Like