---
title: "define(_:_:)"
framework: swift-package-manager
role: symbol
role_heading: Type Method
path: "swift-package-manager/documentation/packagedescription/swiftsetting/define(_:_:)"
---

# define(_:_:)

Defines a compilation condition.

## Declaration

```swift
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

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: #if ENABLE_SOMETHING    ... #endif Unlike macros in C/C++, compilation conditions don’t have an associated value. note: First available in PackageDescription 5.0.

## See Also

### Configuring Swift Settings

- [unsafeFlags(_:_:)](swift-package-manager/documentation/packagedescription/swiftsetting/unsafeflags(_:_:).md)
- [treatAllWarnings(as:_:)](swift-package-manager/documentation/packagedescription/swiftsetting/treatallwarnings(as:_:).md)
- [treatWarning(_:as:_:)](swift-package-manager/documentation/packagedescription/swiftsetting/treatwarning(_:as:_:).md)
