A condition that limits the application of a build setting.


struct BuildSettingCondition


By default, build settings are applicable for all platforms and build configurations. Use the .when modifier to define a build setting for a specific condition. Invalid usage of .when emits an error during manifest parsing. For example, it’s invalid to specify a .when condition with both parameters as nil.

The following example shows how to use build setting conditions with various APIs:

    name: "MyTool",
    dependencies: ["Utility"],
    cSettings: [
        .define("DISABLE_SOMETHING", .when(platforms: [.iOS], configuration: .release)),
    swiftSettings: [
        .define("ENABLE_SOMETHING", .when(configuration: .release)),
    linkerSettings: [
        .linkLibrary("openssl", .when(platforms: [.linux])),


Conforms To

See Also

Configuring the Target

struct BuildConfiguration

The build configuration such as debug or release..

struct CSetting

A C-language build setting.

struct CXXSetting

A CXX-language build setting.

struct SwiftSetting

A Swift language build setting.

struct LinkerSetting

A linker build setting.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software