Skip to content

Commit 7e60027

Browse files
authored
Merge pull request #655 from aciidb0mb3r/include-dir-xcodeproj
[Xcodeproj] Add include group for C lang targets
2 parents bd8caa8 + b6b7fcc commit 7e60027

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Sources/Xcodeproj/pbxproj().swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,17 @@ func xcodeProject(
349349
// Also add the source file to the compile phase.
350350
compilePhase.addBuildFile(fileRef: srcFileRef)
351351
}
352+
353+
// Add the `include` group for a libary C language target.
354+
if case let clangModule as ClangModule = module, clangModule.type == .library, fileSystem.isDirectory(clangModule.includeDir) {
355+
let includeDir = clangModule.includeDir
356+
_ = makeGroup(for: includeDir)
357+
// FIXME: Support C++ headers.
358+
for header in try walk(includeDir, fileSystem: fileSystem) where header.extension == "h" {
359+
let group = makeGroup(for: header.parentDirectory)
360+
group.addFileReference(path: header.basename)
361+
}
362+
}
352363
}
353364

354365
// Go through all the module/target pairs again, and add target dependencies

Tests/XcodeprojTests/PackageGraphTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ class PackageGraphTests: XCTestCase {
4444
"Package.swift",
4545
"Sources/Foo/foo.swift",
4646
"Sources/Sea2/Sea2.c",
47+
"Sources/Sea2/include/Sea2.h",
4748
"Sources/Bar/bar.swift",
4849
"Sources/Sea/Sea.c",
50+
"Sources/Sea/include/Sea.h",
4951
"Tests/BarTests/barTests.swift",
5052
"Products/Foo.framework",
5153
"Products/Sea2.framework",

0 commit comments

Comments
 (0)