<!--
{
  "availability" : [
    "SwiftPM: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PackageDescription",
  "identifier" : "/documentation/PackageDescription/SwiftSetting/define(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "PackageDescription"
    ],
    "preciseIdentifier" : "s:18PackageDescription12SwiftSettingV6defineyACSS_AA05BuildD9ConditionVSgtFZ"
  },
  "title" : "define(_:_:)"
}
-->

# define(_:_:)

Defines a compilation condition.

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

## Parameters

`name`

The name of the macro.

`condition`

A condition that restricts the application of the build
setting.

## Discussion

Use compilation conditions to only compile statements if a certain
condition is true. For example, the Swift compiler will only compile the
statements inside the `#if` block when `ENABLE_SOMETHING` is defined:

```swift
#if ENABLE_SOMETHING
   ...
#endif
```

Unlike macros in C/C++, compilation conditions don’t have an associated
value.

> Since: First available in PackageDescription 5.0.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)