A condition that limits the application of a build setting.
SDK
- Xcode 10.2+
Framework
- Swift Package Manager
Declaration
struct BuildSettingCondition
Overview
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:
...
.target(
name: "MyTool",
dependencies: ["Utility"],
cSettings: [
.headerSearchPath("path/relative/to/my/target"),
.define("DISABLE_SOMETHING", .when(platforms: [.iOS], configuration: .release)),
],
swiftSettings: [
.define("ENABLE_SOMETHING", .when(configuration: .release)),
],
linkerSettings: [
.linkLibrary("openssl", .when(platforms: [.linux])),
]
),