Skip to main content

swift_toolchain

A swift_toolchain() rule defines the Swift compiler and associated tools used to build Swift code in Apple targets. It specifies the swiftc compiler, standard library tools, module paths, SDK paths, and compiler flags. An apple_toolchain() references a swift_toolchain() via its swift_toolchain attribute to enable Swift compilation.

Function Signature

def swift_toolchain(
*,
name: str,
default_target_platform: None | str = None,
target_compatible_with: list[str] = [],
compatible_with: list[str] = [],
exec_compatible_with: list[str] = [],
visibility: list[str] = [],
within_view: list[str] = ["PUBLIC"],
metadata: OpaqueMetadata = {},
tests: list[str] = [],
modifiers: OpaqueMetadata = [],
_apple_platforms: dict[str, str] = {},
_internal_sdk_path: None | str = None,
_swiftc_wrapper: str = "prelude//apple/tools:swift_exec",
architecture: str,
contacts: list[str] = [],
enforce_dedupe_eligibility: bool = False,
labels: list[str] = [],
licenses: list[str] = [],
make_swift_comp_db: str = "prelude//apple/tools:make_swift_comp_db",
make_swift_interface: str = "prelude//apple/tools:make_swift_interface",
object_format: str = "object",
placeholder_tool: None | str = None,
platform_path: None | str = None,
provide_swift_debug_info: bool = True,
resource_dir: None | str = None,
runtime_paths_for_bundling: list[str] = [],
runtime_paths_for_linking: list[str] = [],
sdk_module_path_prefixes: dict[str, str] = {},
sdk_modules: list[str] = [],
sdk_path: None | str = None,
serialized_diags_to_json: None | str = None,
supports_explicit_module_debug_serialization: bool = False,
supports_incremental_file_hashing: bool = False,
supports_modulemaps_with_hmaps: bool = False,
supports_relative_resource_dir: bool = False,
swift_experimental_features: dict[str, list[str]] = {"5": [], "6": []},
swift_ide_test_tool: None | str = None,
swift_stdlib_tool: str,
swift_stdlib_tool_flags: list[str] = [],
swift_upcoming_features: dict[str, list[str]] = {"5": [], "6": []},
swiftc: str,
swiftc_flags: list[str] = [],
use_depsfiles: bool = False,
uses_content_based_paths: bool = False,
) -> None

Parameters

  • name: (required)

    name of the target

  • default_target_platform: (defaults to: None)

    specifies the default target platform, used when no platforms are specified on the command line

  • target_compatible_with: (defaults to: [])

    a list of constraints that are required to be satisfied for this target to be compatible with a configuration

  • compatible_with: (defaults to: [])

    a list of constraints that are required to be satisfied for this target to be compatible with a configuration

  • exec_compatible_with: (defaults to: [])

    a list of constraints that are required to be satisfied for this target to be compatible with an execution platform

  • visibility: (defaults to: [])

    a list of visibility patterns restricting what targets can depend on this one

  • within_view: (defaults to: ["PUBLIC"])

    a list of visibility patterns restricting what this target can depend on

  • metadata: (defaults to: {})

    a key-value map of metadata associated with this target

  • tests: (defaults to: [])

    a list of targets that provide tests for this one

  • modifiers: (defaults to: [])

    an array of modifiers associated with this target

  • contacts: (defaults to: [])

    A list of organizational contacts for this rule. These could be individuals who you would contact in the event of a failure or other issue with the rule.

    contacts = [ 'Joe Sixpack', 'Erika Mustermann' ]
  • labels: (defaults to: [])

    Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using buck query().

  • licenses: (defaults to: [])

    Set of license files for this library. To get the list of license files for a given build rule and all of its dependencies, you can use buck query