Skip to content

Commit 299ae06

Browse files
committed
[Xcodeproj] Add -DSWIFT_PACKAGE=1 to the C/C++ preprocessor defines
It was already set for swift, but needed to be added for C/C++/etc. to match how this works for a command-line `swift build` invocation.
1 parent b3cb538 commit 299ae06

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

Sources/Xcodeproj/pbxproj().swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ func xcodeProject(
147147

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

151152
// Opt out of headermaps. The semantics of the build should be explicitly
152153
// defined by the project structure, so that we don't get any additional

Tests/XcodeprojTests/PackageGraphTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class PackageGraphTests: XCTestCase {
111111
XCTAssertEqual(project.buildSettings.debug.SWIFT_OPTIMIZATION_LEVEL, "-Onone")
112112
XCTAssertEqual(project.buildSettings.debug.SWIFT_ACTIVE_COMPILATION_CONDITIONS!, ["SWIFT_PACKAGE", "DEBUG"])
113113
XCTAssertEqual(project.buildSettings.common.SWIFT_ACTIVE_COMPILATION_CONDITIONS!, ["SWIFT_PACKAGE"])
114+
XCTAssertEqual(project.buildSettings.common.GCC_PREPROCESSOR_DEFINITIONS, ["SWIFT_PACKAGE=1"])
114115

115116
result.check(target: "Foo") { targetResult in
116117
targetResult.check(productType: .framework)

0 commit comments

Comments
 (0)