Hi,
I want to add a new custom flag in my swift package to conditionally compile files, something like this below.
#if DISABLE_FORMAT
// Do nothing
#else
class Formatter {
func format() {
...
}
}
#endif
But I want to introduce this flag only for iOS 15+. I tried the below two approaches, but it is not working,
Added using swiftSettings,
.target(
name: "Localization",
dependencies: [],
swiftSettings: [
.define("DISABLE_FORMAT[sdk=iphoneos15.0]"),
.define("DISABLE_FORMAT[sdk=iphonesimulator15.0]"),
]
)
Added using cSettings,
.target(
name: "Localization",
dependencies: [],
cSettings: [
.unsafeFlags(
[
"-DISABLE_FORMAT[sdk=iphoneos15.0]=1",
"-DISABLE_FORMAT[sdk=iphonesimulator15.0]=1",
], .when(platforms: [.iOS], configuration: .debug)
),
.unsafeFlags(
[
"-DISABLE_FORMAT[sdk=iphoneos15.0]=1",
"-DISABLE_FORMAT[sdk=iphonesimulator15.0]=1",
], .when(platforms: [.iOS], configuration: .release)
),
]
)
I would appreciate any help.