Skip to content

Commit 084a3ce

Browse files
committed
Improve search paths for XCFrameworks
When packaging a Swift dylib as an XCFramework, its modules will be at the top-level, so that directory needs to become part of search paths. fixes #5723
1 parent 630bdea commit 084a3ce

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Sources/Build/BuildPlan.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,8 +2130,8 @@ public class BuildPlan {
21302130
if case .xcframework = target.kind {
21312131
let libraries = try self.parseXCFramework(for: target)
21322132
for library in libraries {
2133-
if let headersPath = library.headersPath {
2134-
clangTarget.additionalFlags += ["-I", headersPath.pathString]
2133+
library.headersPaths.forEach {
2134+
clangTarget.additionalFlags += ["-I", $0.pathString]
21352135
}
21362136
clangTarget.libraryBinaryPaths.insert(library.libraryPath)
21372137
}
@@ -2167,8 +2167,8 @@ public class BuildPlan {
21672167
if case .xcframework = target.kind {
21682168
let libraries = try self.parseXCFramework(for: target)
21692169
for library in libraries {
2170-
if let headersPath = library.headersPath {
2171-
swiftTarget.additionalFlags += ["-Xcc", "-I", "-Xcc", headersPath.pathString]
2170+
library.headersPaths.forEach {
2171+
swiftTarget.additionalFlags += ["-I", $0.pathString, "-Xcc", "-I", "-Xcc", $0.pathString]
21722172
}
21732173
swiftTarget.libraryBinaryPaths.insert(library.libraryPath)
21742174
}

Sources/SPMBuildCore/BinaryTarget+Extensions.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public struct LibraryInfo: Equatable {
2323
/// The path to the binary.
2424
public let libraryPath: AbsolutePath
2525

26-
/// The path to the headers directory, if one exists.
27-
public let headersPath: AbsolutePath?
26+
/// The paths to the headers directories.
27+
public let headersPaths: [AbsolutePath]
2828
}
2929

3030

@@ -54,8 +54,8 @@ extension BinaryTarget {
5454
// Construct a LibraryInfo for the library.
5555
let libraryDir = self.artifactPath.appending(component: library.libraryIdentifier)
5656
let libraryFile = AbsolutePath(library.libraryPath, relativeTo: libraryDir)
57-
let headersDir = library.headersPath.map { AbsolutePath($0, relativeTo: libraryDir) }
58-
return [LibraryInfo(libraryPath: libraryFile, headersPath: headersDir)]
57+
let headersDirs = library.headersPath.map({ [AbsolutePath($0, relativeTo: libraryDir)] }) ?? [] + [libraryDir]
58+
return [LibraryInfo(libraryPath: libraryFile, headersPaths: headersDirs)]
5959
}
6060

6161
public func parseArtifactArchives(for triple: Triple, fileSystem: FileSystem) throws -> [ExecutableInfo] {

0 commit comments

Comments
 (0)