Skip to content

Commit 7661b27

Browse files
committed
Merge pull request #226 from aciidb0mb3r/header_search_path_xcodeproj
Add header search path for c modules during xcodeproj gen
2 parents 9a5ead0 + 1f5f48a commit 7661b27

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Sources/Xcodeproj/Module+PBXProj.swift

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,35 @@ extension SwiftModule {
146146
}
147147
}
148148

149+
var headerSearchPaths: (key: String, value: String)? {
150+
let headerPathKey = "HEADER_SEARCH_PATHS"
151+
let headerPaths = dependencies.filter{$0 is CModule}.map{($0 as! CModule).path}
152+
153+
guard !headerPaths.isEmpty else { return nil }
154+
155+
if headerPaths.count == 1, let first = headerPaths.first {
156+
return (headerPathKey, first)
157+
}
158+
159+
let headerPathValue = "( " + headerPaths.map({ "\"\($0)\"" }).joined(separator: ", ") + " )"
160+
161+
return (headerPathKey, headerPathValue)
162+
}
163+
149164
var debugBuildSettings: String {
150165
var buildSettings = commonBuildSettings
151166
buildSettings["SWIFT_OPTIMIZATION_LEVEL"] = "-Onone"
152-
167+
if let headerSearchPaths = headerSearchPaths {
168+
buildSettings[headerSearchPaths.key] = headerSearchPaths.value
169+
}
153170
return buildSettings.map{ "\($0) = \($1);" }.joined(separator: " ")
154171
}
155172

156173
var releaseBuildSettings: String {
157-
let buildSettings = commonBuildSettings
174+
var buildSettings = commonBuildSettings
175+
if let headerSearchPaths = headerSearchPaths {
176+
buildSettings[headerSearchPaths.key] = headerSearchPaths.value
177+
}
158178
return buildSettings.map{ "\($0) = \($1);" }.joined(separator: " ")
159179
}
160180

0 commit comments

Comments
 (0)