Skip to content

Commit 7d68f81

Browse files
krzyzanowskimaciidgh
authored andcommitted
[SR-6829] Add "DEBUG" to Xcode debug configuration (#1518)
* SWIFT_ACTIVE_COMPILATION_CONDITIONS is a list * Add DEBUG value to SWIFT_ACTIVE_COMPILATION_CONDITIONS for Debug configuration. * Set debug flag during project generation. * Test SWIFT_ACTIVE_COMPILATION_CONDITIONS serialization * Add explicit release case * Add DEBUG to projectSettings.debug.GCC_PREPROCESSOR_DEFINITIONS * Add activeCompilationConditions to the Clang targets * Update BuildPlan tests.
1 parent 96fdd97 commit 7d68f81

File tree

5 files changed

+116
-21
lines changed

5 files changed

+116
-21
lines changed

Sources/Build/BuildPlan.swift

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ public final class ClangTargetDescription {
199199
var args = [String]()
200200
args += buildParameters.toolchain.extraCCFlags
201201
args += optimizationArguments
202+
args += activeCompilationConditions
202203

203204
// Only enable ARC on macOS.
204205
#if os(macOS)
@@ -230,6 +231,21 @@ public final class ClangTargetDescription {
230231
}
231232
}
232233

234+
/// A list of compilation conditions to enable for conditional compilation expressions.
235+
private var activeCompilationConditions: [String] {
236+
var compilationConditions = ["-DSWIFT_PACKAGE=1"]
237+
238+
switch buildParameters.configuration {
239+
case .debug:
240+
compilationConditions += ["-DDEBUG=1"]
241+
case .release:
242+
break
243+
}
244+
245+
return compilationConditions
246+
}
247+
248+
233249
/// Helper function to compute the modulemap path.
234250
///
235251
/// This function either returns path to user provided modulemap or tries to automatically generates it.
@@ -303,7 +319,8 @@ public final class SwiftTargetDescription {
303319
args += ["-swift-version", String(swiftVersion)]
304320
args += buildParameters.toolchain.extraSwiftCFlags
305321
args += optimizationArguments
306-
args += ["-j\(SwiftCompilerTool.numThreads)", "-DSWIFT_PACKAGE"]
322+
args += ["-j\(SwiftCompilerTool.numThreads)"]
323+
args += activeCompilationConditions
307324
args += additionalFlags
308325
args += moduleCacheArgs
309326

@@ -317,6 +334,20 @@ public final class SwiftTargetDescription {
317334
return args
318335
}
319336

337+
/// A list of compilation conditions to enable for conditional compilation expressions.
338+
private var activeCompilationConditions: [String] {
339+
var compilationConditions = ["-DSWIFT_PACKAGE"]
340+
341+
switch buildParameters.configuration {
342+
case .debug:
343+
compilationConditions += ["-DDEBUG"]
344+
case .release:
345+
break
346+
}
347+
348+
return compilationConditions
349+
}
350+
320351
/// Optimization arguments according to the build configuration.
321352
private var optimizationArguments: [String] {
322353
switch buildParameters.configuration {

Sources/Xcodeproj/XcodeProjectModel.swift

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ public struct Xcode {
348348
var FRAMEWORK_SEARCH_PATHS: [String]?
349349
var GCC_C_LANGUAGE_STANDARD: String?
350350
var GCC_OPTIMIZATION_LEVEL: String?
351+
var GCC_PREPROCESSOR_DEFINITIONS: [String]?
351352
var HEADER_SEARCH_PATHS: [String]?
352353
var INFOPLIST_FILE: String?
353354
var LD_RUNPATH_SEARCH_PATHS: [String]?
@@ -365,14 +366,56 @@ public struct Xcode {
365366
var SDKROOT: String?
366367
var SKIP_INSTALL: String?
367368
var SUPPORTED_PLATFORMS: [String]?
368-
var SWIFT_ACTIVE_COMPILATION_CONDITIONS: String?
369+
var SWIFT_ACTIVE_COMPILATION_CONDITIONS: [String]?
369370
var SWIFT_FORCE_STATIC_LINK_STDLIB: String?
370371
var SWIFT_FORCE_DYNAMIC_LINK_STDLIB: String?
371372
var SWIFT_OPTIMIZATION_LEVEL: String?
372373
var SWIFT_VERSION: String?
373374
var TARGET_NAME: String?
374375
var USE_HEADERMAP: String?
375376
var LD: String?
377+
378+
init(CLANG_CXX_LANGUAGE_STANDARD: String? = nil, CLANG_ENABLE_OBJC_ARC: String? = nil, COMBINE_HIDPI_IMAGES: String? = nil, COPY_PHASE_STRIP: String? = nil, DEBUG_INFORMATION_FORMAT: String? = nil, DEFINES_MODULE: String? = nil, DYLIB_INSTALL_NAME_BASE: String? = nil, EMBEDDED_CONTENT_CONTAINS_SWIFT: String? = nil, ENABLE_NS_ASSERTIONS: String? = nil, ENABLE_TESTABILITY: String? = nil, FRAMEWORK_SEARCH_PATHS: [String]? = nil, GCC_C_LANGUAGE_STANDARD: String? = nil, GCC_OPTIMIZATION_LEVEL: String? = nil, GCC_PREPROCESSOR_DEFINITIONS: [String]? = nil, HEADER_SEARCH_PATHS: [String]? = nil, INFOPLIST_FILE: String? = nil, LD_RUNPATH_SEARCH_PATHS: [String]? = nil, LIBRARY_SEARCH_PATHS: [String]? = nil, MACOSX_DEPLOYMENT_TARGET: String? = nil, MODULEMAP_FILE: String? = nil, ONLY_ACTIVE_ARCH: String? = nil, OTHER_CFLAGS: [String]? = nil, OTHER_LDFLAGS: [String]? = nil, OTHER_SWIFT_FLAGS: [String]? = nil, PRODUCT_BUNDLE_IDENTIFIER: String? = nil, PRODUCT_MODULE_NAME: String? = nil, PRODUCT_NAME: String? = nil, PROJECT_NAME: String? = nil, SDKROOT: String? = nil, SKIP_INSTALL: String? = nil, SUPPORTED_PLATFORMS: [String]? = nil, SWIFT_ACTIVE_COMPILATION_CONDITIONS: [String]? = nil, SWIFT_FORCE_STATIC_LINK_STDLIB: String? = nil, SWIFT_FORCE_DYNAMIC_LINK_STDLIB: String? = nil, SWIFT_OPTIMIZATION_LEVEL: String? = nil, SWIFT_VERSION: String? = nil, TARGET_NAME: String? = nil, USE_HEADERMAP: String? = nil, LD: String? = nil) {
379+
self.CLANG_CXX_LANGUAGE_STANDARD = CLANG_CXX_LANGUAGE_STANDARD
380+
self.CLANG_ENABLE_OBJC_ARC = CLANG_CXX_LANGUAGE_STANDARD
381+
self.COMBINE_HIDPI_IMAGES = COMBINE_HIDPI_IMAGES
382+
self.COPY_PHASE_STRIP = COPY_PHASE_STRIP
383+
self.DEBUG_INFORMATION_FORMAT = DEBUG_INFORMATION_FORMAT
384+
self.DEFINES_MODULE = DEFINES_MODULE
385+
self.DYLIB_INSTALL_NAME_BASE = DYLIB_INSTALL_NAME_BASE
386+
self.EMBEDDED_CONTENT_CONTAINS_SWIFT = EMBEDDED_CONTENT_CONTAINS_SWIFT
387+
self.ENABLE_NS_ASSERTIONS = ENABLE_NS_ASSERTIONS
388+
self.ENABLE_TESTABILITY = ENABLE_TESTABILITY
389+
self.FRAMEWORK_SEARCH_PATHS = FRAMEWORK_SEARCH_PATHS
390+
self.GCC_C_LANGUAGE_STANDARD = GCC_C_LANGUAGE_STANDARD
391+
self.GCC_OPTIMIZATION_LEVEL = GCC_OPTIMIZATION_LEVEL
392+
self.GCC_PREPROCESSOR_DEFINITIONS = GCC_PREPROCESSOR_DEFINITIONS
393+
self.HEADER_SEARCH_PATHS = HEADER_SEARCH_PATHS
394+
self.INFOPLIST_FILE = INFOPLIST_FILE
395+
self.LD_RUNPATH_SEARCH_PATHS = LD_RUNPATH_SEARCH_PATHS
396+
self.LIBRARY_SEARCH_PATHS = LIBRARY_SEARCH_PATHS
397+
self.MACOSX_DEPLOYMENT_TARGET = MACOSX_DEPLOYMENT_TARGET
398+
self.MODULEMAP_FILE = MODULEMAP_FILE
399+
self.ONLY_ACTIVE_ARCH = ONLY_ACTIVE_ARCH
400+
self.OTHER_CFLAGS = OTHER_CFLAGS
401+
self.OTHER_LDFLAGS = OTHER_LDFLAGS
402+
self.OTHER_SWIFT_FLAGS = OTHER_SWIFT_FLAGS
403+
self.PRODUCT_BUNDLE_IDENTIFIER = PRODUCT_BUNDLE_IDENTIFIER
404+
self.PRODUCT_MODULE_NAME = PRODUCT_MODULE_NAME
405+
self.PRODUCT_NAME = PRODUCT_NAME
406+
self.PROJECT_NAME = PROJECT_NAME
407+
self.SDKROOT = SDKROOT
408+
self.SKIP_INSTALL = SKIP_INSTALL
409+
self.SUPPORTED_PLATFORMS = SUPPORTED_PLATFORMS
410+
self.SWIFT_ACTIVE_COMPILATION_CONDITIONS = SWIFT_ACTIVE_COMPILATION_CONDITIONS
411+
self.SWIFT_FORCE_STATIC_LINK_STDLIB = SWIFT_FORCE_STATIC_LINK_STDLIB
412+
self.SWIFT_FORCE_DYNAMIC_LINK_STDLIB = SWIFT_FORCE_DYNAMIC_LINK_STDLIB
413+
self.SWIFT_OPTIMIZATION_LEVEL = SWIFT_OPTIMIZATION_LEVEL
414+
self.SWIFT_VERSION = SWIFT_VERSION
415+
self.TARGET_NAME = TARGET_NAME
416+
self.USE_HEADERMAP = USE_HEADERMAP
417+
self.LD = LD
418+
}
376419
}
377420
}
378421
}

Sources/Xcodeproj/pbxproj().swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func xcodeProject(
147147
projectSettings.common.COMBINE_HIDPI_IMAGES = "YES"
148148

149149
// Defined for regular `swift build` instantiations, so also should be defined here.
150-
projectSettings.common.SWIFT_ACTIVE_COMPILATION_CONDITIONS = "SWIFT_PACKAGE"
150+
projectSettings.common.SWIFT_ACTIVE_COMPILATION_CONDITIONS += ["SWIFT_PACKAGE"]
151151

152152
// Opt out of headermaps. The semantics of the build should be explicitly
153153
// defined by the project structure, so that we don't get any additional
@@ -162,8 +162,10 @@ func xcodeProject(
162162
projectSettings.debug.DEBUG_INFORMATION_FORMAT = "dwarf"
163163
projectSettings.debug.ENABLE_NS_ASSERTIONS = "YES"
164164
projectSettings.debug.GCC_OPTIMIZATION_LEVEL = "0"
165+
projectSettings.debug.GCC_PREPROCESSOR_DEFINITIONS = ["DEBUG=1", "$(inherited)"]
165166
projectSettings.debug.ONLY_ACTIVE_ARCH = "YES"
166167
projectSettings.debug.SWIFT_OPTIMIZATION_LEVEL = "-Onone"
168+
projectSettings.debug.SWIFT_ACTIVE_COMPILATION_CONDITIONS += ["DEBUG"]
167169

168170
// Add some release-specific settings.
169171
projectSettings.release.COPY_PHASE_STRIP = "YES"
@@ -452,6 +454,7 @@ func xcodeProject(
452454
targetSettings.common.OTHER_CFLAGS = ["$(inherited)"]
453455
targetSettings.common.OTHER_LDFLAGS = ["$(inherited)"]
454456
targetSettings.common.OTHER_SWIFT_FLAGS = ["$(inherited)"]
457+
targetSettings.common.SWIFT_ACTIVE_COMPILATION_CONDITIONS = ["$(inherited)"]
455458

456459
// Set the correct SWIFT_VERSION for the Swift targets.
457460
if case let swiftTarget as SwiftTarget = target.underlyingTarget {

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ final class BuildPlanTests: XCTestCase {
7878
result.checkTargetsCount(2)
7979

8080
let exe = try result.target(for: "exe").swiftTarget().compileArguments()
81-
XCTAssertMatch(exe, ["-swift-version", "3", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
81+
XCTAssertMatch(exe, ["-swift-version", "3", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-DDEBUG", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
8282

8383
let lib = try result.target(for: "lib").swiftTarget().compileArguments()
84-
XCTAssertMatch(lib, ["-swift-version", "3", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
84+
XCTAssertMatch(lib, ["-swift-version", "3", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-DDEBUG", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
8585

8686
#if os(macOS)
8787
let linkArguments = [
@@ -211,7 +211,7 @@ final class BuildPlanTests: XCTestCase {
211211
result.checkTargetsCount(3)
212212

213213
let ext = try result.target(for: "extlib").clangTarget()
214-
var args = ["-g", "-O0"]
214+
var args = ["-g", "-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1"]
215215
#if os(macOS)
216216
args += ["-fobjc-arc"]
217217
#endif
@@ -222,7 +222,7 @@ final class BuildPlanTests: XCTestCase {
222222
XCTAssertEqual(ext.moduleMap, AbsolutePath("/path/to/build/debug/extlib.build/module.modulemap"))
223223

224224
let exe = try result.target(for: "exe").clangTarget()
225-
args = ["-g", "-O0"]
225+
args = ["-g", "-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1"]
226226
#if os(macOS)
227227
args += ["-fobjc-arc"]
228228
#endif
@@ -324,7 +324,7 @@ final class BuildPlanTests: XCTestCase {
324324
result.checkTargetsCount(2)
325325

326326
let lib = try result.target(for: "lib").clangTarget()
327-
var args = ["-g", "-O0"]
327+
var args = ["-g", "-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1"]
328328
#if os(macOS)
329329
args += ["-fobjc-arc"]
330330
#endif
@@ -335,7 +335,7 @@ final class BuildPlanTests: XCTestCase {
335335
XCTAssertEqual(lib.moduleMap, AbsolutePath("/path/to/build/debug/lib.build/module.modulemap"))
336336

337337
let exe = try result.target(for: "exe").swiftTarget().compileArguments()
338-
XCTAssertMatch(exe, ["-swift-version", "3", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-Xcc", "-fmodule-map-file=/path/to/build/debug/lib.build/module.modulemap", "-I", "/Pkg/Sources/lib/include", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
338+
XCTAssertMatch(exe, ["-swift-version", "3", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-DDEBUG","-Xcc", "-fmodule-map-file=/path/to/build/debug/lib.build/module.modulemap", "-I", "/Pkg/Sources/lib/include", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
339339

340340
#if os(macOS)
341341
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
@@ -372,10 +372,10 @@ final class BuildPlanTests: XCTestCase {
372372
#endif
373373

374374
let foo = try result.target(for: "Foo").swiftTarget().compileArguments()
375-
XCTAssertMatch(foo, ["-swift-version", "3", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
375+
XCTAssertMatch(foo, ["-swift-version", "3", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-DDEBUG", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
376376

377377
let fooTests = try result.target(for: "FooTests").swiftTarget().compileArguments()
378-
XCTAssertMatch(fooTests, ["-swift-version", "3", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
378+
XCTAssertMatch(fooTests, ["-swift-version", "3", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-DDEBUG", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
379379

380380
#if os(macOS)
381381
XCTAssertEqual(try result.buildProduct(for: "PkgPackageTests").linkArguments(), [
@@ -413,7 +413,7 @@ final class BuildPlanTests: XCTestCase {
413413
result.checkProductsCount(1)
414414
result.checkTargetsCount(1)
415415

416-
XCTAssertMatch(try result.target(for: "exe").swiftTarget().compileArguments(), ["-swift-version", "3", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-Xcc", "-fmodule-map-file=/Clibgit/module.modulemap", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
416+
XCTAssertMatch(try result.target(for: "exe").swiftTarget().compileArguments(), ["-swift-version", "3", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-DDEBUG", "-Xcc", "-fmodule-map-file=/Clibgit/module.modulemap", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
417417

418418
#if os(macOS)
419419
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
@@ -552,10 +552,10 @@ final class BuildPlanTests: XCTestCase {
552552
result.checkTargetsCount(2)
553553

554554
let exe = try result.target(for: "exe").swiftTarget().compileArguments()
555-
XCTAssertMatch(exe, ["-swift-version", "4", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
555+
XCTAssertMatch(exe, ["-swift-version", "4", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-DDEBUG", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
556556

557557
let lib = try result.target(for: "lib").swiftTarget().compileArguments()
558-
XCTAssertMatch(lib, ["-swift-version", "4", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
558+
XCTAssertMatch(lib, ["-swift-version", "4", "-Onone", "-g", "-enable-testing", .equal(j), "-DSWIFT_PACKAGE", "-DDEBUG", "-module-cache-path", "/path/to/build/debug/ModuleCache", .anySequence])
559559

560560
#if os(macOS)
561561
let linkArguments = [
@@ -605,18 +605,18 @@ final class BuildPlanTests: XCTestCase {
605605

606606
let exe = try result.target(for: "exe").clangTarget()
607607
#if os(macOS)
608-
XCTAssertEqual(exe.basicArguments(), ["-g", "-O0", "-fobjc-arc","-fblocks", "-fmodules", "-fmodule-name=exe", "-I", "/Pkg/Sources/exe/include", "-fmodules-cache-path=/path/to/build/debug/ModuleCache"])
608+
XCTAssertEqual(exe.basicArguments(), ["-g", "-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1", "-fobjc-arc","-fblocks", "-fmodules", "-fmodule-name=exe", "-I", "/Pkg/Sources/exe/include", "-fmodules-cache-path=/path/to/build/debug/ModuleCache"])
609609
#else
610-
XCTAssertEqual(exe.basicArguments(), ["-g", "-O0","-fblocks", "-fmodules", "-fmodule-name=exe", "-I", "/Pkg/Sources/exe/include", "-fmodules-cache-path=/path/to/build/debug/ModuleCache"])
610+
XCTAssertEqual(exe.basicArguments(), ["-g", "-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1", "-fblocks", "-fmodules", "-fmodule-name=exe", "-I", "/Pkg/Sources/exe/include", "-fmodules-cache-path=/path/to/build/debug/ModuleCache"])
611611
#endif
612612
XCTAssertEqual(exe.objects, [AbsolutePath("/path/to/build/debug/exe.build/main.c.o")])
613613
XCTAssertEqual(exe.moduleMap, nil)
614614

615615
let lib = try result.target(for: "lib").clangTarget()
616616
#if os(macOS)
617-
XCTAssertEqual(lib.basicArguments(), ["-g", "-O0", "-fobjc-arc","-fblocks", "-fmodules", "-fmodule-name=lib", "-I", "/Pkg/Sources/lib/include", "-fmodules-cache-path=/path/to/build/debug/ModuleCache"])
617+
XCTAssertEqual(lib.basicArguments(), ["-g", "-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1", "-fobjc-arc","-fblocks", "-fmodules", "-fmodule-name=lib", "-I", "/Pkg/Sources/lib/include", "-fmodules-cache-path=/path/to/build/debug/ModuleCache"])
618618
#else
619-
XCTAssertEqual(lib.basicArguments(), ["-g", "-O0","-fblocks", "-fmodules", "-fmodule-name=lib", "-I", "/Pkg/Sources/lib/include", "-fmodules-cache-path=/path/to/build/debug/ModuleCache"])
619+
XCTAssertEqual(lib.basicArguments(), ["-g", "-O0", "-DSWIFT_PACKAGE=1", "-DDEBUG=1", "-fblocks", "-fmodules", "-fmodule-name=lib", "-I", "/Pkg/Sources/lib/include", "-fmodules-cache-path=/path/to/build/debug/ModuleCache"])
620620
#endif
621621
XCTAssertEqual(lib.objects, [AbsolutePath("/path/to/build/debug/lib.build/lib.cpp.o")])
622622
XCTAssertEqual(lib.moduleMap, AbsolutePath("/path/to/build/debug/lib.build/module.modulemap"))

Tests/XcodeprojTests/XcodeProjectModelSerializationTests.swift

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ class XcodeProjectModelSerializationTests: XCTestCase {
8686
let otherSwiftFlagValues = ["$(inherited)", "-DXcode"]
8787
buildSettings.OTHER_SWIFT_FLAGS = otherSwiftFlagValues
8888

89+
let activeCompilationConditionsValues = ["$(inherited)", "DEBUG"]
90+
buildSettings.SWIFT_ACTIVE_COMPILATION_CONDITIONS = activeCompilationConditionsValues
91+
8992
// Serialize it to a property list.
9093
let plist = buildSettings.asPropertyList()
9194

@@ -97,9 +100,10 @@ class XcodeProjectModelSerializationTests: XCTestCase {
97100

98101
guard
99102
let productNamePlist = buildSettingsDict["PRODUCT_NAME"],
100-
let otherSwiftFlagsPlist = buildSettingsDict["OTHER_SWIFT_FLAGS"]
103+
let otherSwiftFlagsPlist = buildSettingsDict["OTHER_SWIFT_FLAGS"],
104+
let activeCompilationConditionsPlist = buildSettingsDict["SWIFT_ACTIVE_COMPILATION_CONDITIONS"]
101105
else {
102-
XCTFail("build settings plist must contain PRODUCT_NAME and OTHER_SWIFT_FLAGS")
106+
XCTFail("build settings plist must contain PRODUCT_NAME and OTHER_SWIFT_FLAGS and SWIFT_ACTIVE_COMPILATION_CONDITIONS")
103107
return
104108
}
105109

@@ -113,7 +117,7 @@ class XcodeProjectModelSerializationTests: XCTestCase {
113117
XCTFail("otherSwiftFlags plist must be an array")
114118
return
115119
}
116-
120+
117121
let otherSwiftFlags = otherSwiftFlagsPlists.compactMap { flagPlist -> String? in
118122
guard case let .string(flag) = flagPlist else {
119123
XCTFail("otherSwiftFlag plist must be string")
@@ -122,6 +126,20 @@ class XcodeProjectModelSerializationTests: XCTestCase {
122126
return flag
123127
}
124128
XCTAssertEqual(otherSwiftFlags, otherSwiftFlagValues)
129+
130+
guard case let .array(activeCompilationConditionsPlists) = activeCompilationConditionsPlist else {
131+
XCTFail("activeCompilationConditionsPlist plist must be an array")
132+
return
133+
}
134+
135+
let activeCompilationConditions = activeCompilationConditionsPlists.compactMap { flagPlist -> String? in
136+
guard case let .string(flag) = flagPlist else {
137+
XCTFail("activeCompilationConditions plist must be a string")
138+
return nil
139+
}
140+
return flag
141+
}
142+
XCTAssertEqual(activeCompilationConditions, activeCompilationConditionsValues)
125143
}
126144

127145
static var allTests = [

0 commit comments

Comments
 (0)