Skip to content

[SR-6829] Add "DEBUG" to Xcode debug configuration #1518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion Sources/Build/BuildPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public final class ClangTargetDescription {
var args = [String]()
args += buildParameters.toolchain.extraCCFlags
args += optimizationArguments
args += activeCompilationConditions

// Only enable ARC on macOS.
#if os(macOS)
Expand Down Expand Up @@ -230,6 +231,21 @@ public final class ClangTargetDescription {
}
}

/// A list of compilation conditions to enable for conditional compilation expressions.
private var activeCompilationConditions: [String] {
var compilationConditions = ["-DSWIFT_PACKAGE=1"]

switch buildParameters.configuration {
case .debug:
compilationConditions += ["-DDEBUG=1"]
case .release:
break
}

return compilationConditions
}


/// Helper function to compute the modulemap path.
///
/// This function either returns path to user provided modulemap or tries to automatically generates it.
Expand Down Expand Up @@ -303,7 +319,8 @@ public final class SwiftTargetDescription {
args += ["-swift-version", String(swiftVersion)]
args += buildParameters.toolchain.extraSwiftCFlags
args += optimizationArguments
args += ["-j\(SwiftCompilerTool.numThreads)", "-DSWIFT_PACKAGE"]
args += ["-j\(SwiftCompilerTool.numThreads)"]
args += activeCompilationConditions
args += additionalFlags
args += moduleCacheArgs

Expand All @@ -317,6 +334,20 @@ public final class SwiftTargetDescription {
return args
}

/// A list of compilation conditions to enable for conditional compilation expressions.
private var activeCompilationConditions: [String] {
var compilationConditions = ["-DSWIFT_PACKAGE"]

switch buildParameters.configuration {
case .debug:
compilationConditions += ["-DDEBUG"]
Copy link
Contributor

@aciidgh aciidgh Mar 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I wonder if we should also add this define to C language targets. /cc @ddunbar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tha makes sense. Should go to the GCC_PREPROCESSOR_DEFINITIONS (that's where the Xcode put it for newly created projects)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

along with the -DSWIFT_PACKAGE=1 or... is it set already?

case .release:
break
}

return compilationConditions
}

/// Optimization arguments according to the build configuration.
private var optimizationArguments: [String] {
switch buildParameters.configuration {
Expand Down
45 changes: 44 additions & 1 deletion Sources/Xcodeproj/XcodeProjectModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ public struct Xcode {
var FRAMEWORK_SEARCH_PATHS: [String]?
var GCC_C_LANGUAGE_STANDARD: String?
var GCC_OPTIMIZATION_LEVEL: String?
var GCC_PREPROCESSOR_DEFINITIONS: [String]?
var HEADER_SEARCH_PATHS: [String]?
var INFOPLIST_FILE: String?
var LD_RUNPATH_SEARCH_PATHS: [String]?
Expand All @@ -365,14 +366,56 @@ public struct Xcode {
var SDKROOT: String?
var SKIP_INSTALL: String?
var SUPPORTED_PLATFORMS: [String]?
var SWIFT_ACTIVE_COMPILATION_CONDITIONS: String?
var SWIFT_ACTIVE_COMPILATION_CONDITIONS: [String]?
var SWIFT_FORCE_STATIC_LINK_STDLIB: String?
var SWIFT_FORCE_DYNAMIC_LINK_STDLIB: String?
var SWIFT_OPTIMIZATION_LEVEL: String?
var SWIFT_VERSION: String?
var TARGET_NAME: String?
var USE_HEADERMAP: String?
var LD: String?

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) {
self.CLANG_CXX_LANGUAGE_STANDARD = CLANG_CXX_LANGUAGE_STANDARD
self.CLANG_ENABLE_OBJC_ARC = CLANG_CXX_LANGUAGE_STANDARD
self.COMBINE_HIDPI_IMAGES = COMBINE_HIDPI_IMAGES
self.COPY_PHASE_STRIP = COPY_PHASE_STRIP
self.DEBUG_INFORMATION_FORMAT = DEBUG_INFORMATION_FORMAT
self.DEFINES_MODULE = DEFINES_MODULE
self.DYLIB_INSTALL_NAME_BASE = DYLIB_INSTALL_NAME_BASE
self.EMBEDDED_CONTENT_CONTAINS_SWIFT = EMBEDDED_CONTENT_CONTAINS_SWIFT
self.ENABLE_NS_ASSERTIONS = ENABLE_NS_ASSERTIONS
self.ENABLE_TESTABILITY = ENABLE_TESTABILITY
self.FRAMEWORK_SEARCH_PATHS = FRAMEWORK_SEARCH_PATHS
self.GCC_C_LANGUAGE_STANDARD = GCC_C_LANGUAGE_STANDARD
self.GCC_OPTIMIZATION_LEVEL = GCC_OPTIMIZATION_LEVEL
self.GCC_PREPROCESSOR_DEFINITIONS = GCC_PREPROCESSOR_DEFINITIONS
self.HEADER_SEARCH_PATHS = HEADER_SEARCH_PATHS
self.INFOPLIST_FILE = INFOPLIST_FILE
self.LD_RUNPATH_SEARCH_PATHS = LD_RUNPATH_SEARCH_PATHS
self.LIBRARY_SEARCH_PATHS = LIBRARY_SEARCH_PATHS
self.MACOSX_DEPLOYMENT_TARGET = MACOSX_DEPLOYMENT_TARGET
self.MODULEMAP_FILE = MODULEMAP_FILE
self.ONLY_ACTIVE_ARCH = ONLY_ACTIVE_ARCH
self.OTHER_CFLAGS = OTHER_CFLAGS
self.OTHER_LDFLAGS = OTHER_LDFLAGS
self.OTHER_SWIFT_FLAGS = OTHER_SWIFT_FLAGS
self.PRODUCT_BUNDLE_IDENTIFIER = PRODUCT_BUNDLE_IDENTIFIER
self.PRODUCT_MODULE_NAME = PRODUCT_MODULE_NAME
self.PRODUCT_NAME = PRODUCT_NAME
self.PROJECT_NAME = PROJECT_NAME
self.SDKROOT = SDKROOT
self.SKIP_INSTALL = SKIP_INSTALL
self.SUPPORTED_PLATFORMS = SUPPORTED_PLATFORMS
self.SWIFT_ACTIVE_COMPILATION_CONDITIONS = SWIFT_ACTIVE_COMPILATION_CONDITIONS
self.SWIFT_FORCE_STATIC_LINK_STDLIB = SWIFT_FORCE_STATIC_LINK_STDLIB
self.SWIFT_FORCE_DYNAMIC_LINK_STDLIB = SWIFT_FORCE_DYNAMIC_LINK_STDLIB
self.SWIFT_OPTIMIZATION_LEVEL = SWIFT_OPTIMIZATION_LEVEL
self.SWIFT_VERSION = SWIFT_VERSION
self.TARGET_NAME = TARGET_NAME
self.USE_HEADERMAP = USE_HEADERMAP
self.LD = LD
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion Sources/Xcodeproj/pbxproj().swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func xcodeProject(
projectSettings.common.COMBINE_HIDPI_IMAGES = "YES"

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

// Opt out of headermaps. The semantics of the build should be explicitly
// defined by the project structure, so that we don't get any additional
Expand All @@ -162,8 +162,10 @@ func xcodeProject(
projectSettings.debug.DEBUG_INFORMATION_FORMAT = "dwarf"
projectSettings.debug.ENABLE_NS_ASSERTIONS = "YES"
projectSettings.debug.GCC_OPTIMIZATION_LEVEL = "0"
projectSettings.debug.GCC_PREPROCESSOR_DEFINITIONS = ["DEBUG=1", "$(inherited)"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be projectSettings.debug.GCC_PREPROCESSOR_DEFINITIONS = ["$(inherited)", "DEBUG=1"]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I KNOW. but... it's the other way around in the newly created Xcode project.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷‍♂️okay then

projectSettings.debug.ONLY_ACTIVE_ARCH = "YES"
projectSettings.debug.SWIFT_OPTIMIZATION_LEVEL = "-Onone"
projectSettings.debug.SWIFT_ACTIVE_COMPILATION_CONDITIONS += ["DEBUG"]

// Add some release-specific settings.
projectSettings.release.COPY_PHASE_STRIP = "YES"
Expand Down Expand Up @@ -452,6 +454,7 @@ func xcodeProject(
targetSettings.common.OTHER_CFLAGS = ["$(inherited)"]
targetSettings.common.OTHER_LDFLAGS = ["$(inherited)"]
targetSettings.common.OTHER_SWIFT_FLAGS = ["$(inherited)"]
targetSettings.common.SWIFT_ACTIVE_COMPILATION_CONDITIONS = ["$(inherited)"]

// Set the correct SWIFT_VERSION for the Swift targets.
if case let swiftTarget as SwiftTarget = target.underlyingTarget {
Expand Down
30 changes: 15 additions & 15 deletions Tests/BuildTests/BuildPlanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ final class BuildPlanTests: XCTestCase {
result.checkTargetsCount(2)

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

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

#if os(macOS)
let linkArguments = [
Expand Down Expand Up @@ -211,7 +211,7 @@ final class BuildPlanTests: XCTestCase {
result.checkTargetsCount(3)

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

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

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

let exe = try result.target(for: "exe").swiftTarget().compileArguments()
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])
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])

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

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

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

#if os(macOS)
XCTAssertEqual(try result.buildProduct(for: "PkgPackageTests").linkArguments(), [
Expand Down Expand Up @@ -413,7 +413,7 @@ final class BuildPlanTests: XCTestCase {
result.checkProductsCount(1)
result.checkTargetsCount(1)

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])
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])

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

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

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

#if os(macOS)
let linkArguments = [
Expand Down Expand Up @@ -605,18 +605,18 @@ final class BuildPlanTests: XCTestCase {

let exe = try result.target(for: "exe").clangTarget()
#if os(macOS)
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"])
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"])
#else
XCTAssertEqual(exe.basicArguments(), ["-g", "-O0","-fblocks", "-fmodules", "-fmodule-name=exe", "-I", "/Pkg/Sources/exe/include", "-fmodules-cache-path=/path/to/build/debug/ModuleCache"])
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"])
#endif
XCTAssertEqual(exe.objects, [AbsolutePath("/path/to/build/debug/exe.build/main.c.o")])
XCTAssertEqual(exe.moduleMap, nil)

let lib = try result.target(for: "lib").clangTarget()
#if os(macOS)
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"])
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"])
#else
XCTAssertEqual(lib.basicArguments(), ["-g", "-O0","-fblocks", "-fmodules", "-fmodule-name=lib", "-I", "/Pkg/Sources/lib/include", "-fmodules-cache-path=/path/to/build/debug/ModuleCache"])
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"])
#endif
XCTAssertEqual(lib.objects, [AbsolutePath("/path/to/build/debug/lib.build/lib.cpp.o")])
XCTAssertEqual(lib.moduleMap, AbsolutePath("/path/to/build/debug/lib.build/module.modulemap"))
Expand Down
24 changes: 21 additions & 3 deletions Tests/XcodeprojTests/XcodeProjectModelSerializationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class XcodeProjectModelSerializationTests: XCTestCase {
let otherSwiftFlagValues = ["$(inherited)", "-DXcode"]
buildSettings.OTHER_SWIFT_FLAGS = otherSwiftFlagValues

let activeCompilationConditionsValues = ["$(inherited)", "DEBUG"]
buildSettings.SWIFT_ACTIVE_COMPILATION_CONDITIONS = activeCompilationConditionsValues

// Serialize it to a property list.
let plist = buildSettings.asPropertyList()

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

guard
let productNamePlist = buildSettingsDict["PRODUCT_NAME"],
let otherSwiftFlagsPlist = buildSettingsDict["OTHER_SWIFT_FLAGS"]
let otherSwiftFlagsPlist = buildSettingsDict["OTHER_SWIFT_FLAGS"],
let activeCompilationConditionsPlist = buildSettingsDict["SWIFT_ACTIVE_COMPILATION_CONDITIONS"]
else {
XCTFail("build settings plist must contain PRODUCT_NAME and OTHER_SWIFT_FLAGS")
XCTFail("build settings plist must contain PRODUCT_NAME and OTHER_SWIFT_FLAGS and SWIFT_ACTIVE_COMPILATION_CONDITIONS")
return
}

Expand All @@ -113,7 +117,7 @@ class XcodeProjectModelSerializationTests: XCTestCase {
XCTFail("otherSwiftFlags plist must be an array")
return
}

let otherSwiftFlags = otherSwiftFlagsPlists.compactMap { flagPlist -> String? in
guard case let .string(flag) = flagPlist else {
XCTFail("otherSwiftFlag plist must be string")
Expand All @@ -122,6 +126,20 @@ class XcodeProjectModelSerializationTests: XCTestCase {
return flag
}
XCTAssertEqual(otherSwiftFlags, otherSwiftFlagValues)

guard case let .array(activeCompilationConditionsPlists) = activeCompilationConditionsPlist else {
XCTFail("activeCompilationConditionsPlist plist must be an array")
return
}

let activeCompilationConditions = activeCompilationConditionsPlists.compactMap { flagPlist -> String? in
guard case let .string(flag) = flagPlist else {
XCTFail("activeCompilationConditions plist must be a string")
return nil
}
return flag
}
XCTAssertEqual(activeCompilationConditions, activeCompilationConditionsValues)
}

static var allTests = [
Expand Down