Skip to content

Commit aa9c0cc

Browse files
committed
Add header search path for c modules during xcodeproj gen
1 parent 2c588fd commit aa9c0cc

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

Sources/Xcodeproj/Module+PBXProj.swift

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,39 @@ 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+
var headerPathValue = "(\n"
160+
for header in headerPaths {
161+
headerPathValue += "\"\(header)\","
162+
}
163+
headerPathValue += ")"
164+
165+
return (headerPathKey, headerPathValue)
166+
}
167+
149168
var debugBuildSettings: String {
150169
var buildSettings = commonBuildSettings
151170
buildSettings["SWIFT_OPTIMIZATION_LEVEL"] = "-Onone"
152-
171+
if let headerSearchPaths = headerSearchPaths {
172+
buildSettings[headerSearchPaths.key] = headerSearchPaths.value
173+
}
153174
return buildSettings.map{ "\($0) = \($1);" }.joined(separator: " ")
154175
}
155176

156177
var releaseBuildSettings: String {
157-
let buildSettings = commonBuildSettings
178+
var buildSettings = commonBuildSettings
179+
if let headerSearchPaths = headerSearchPaths {
180+
buildSettings[headerSearchPaths.key] = headerSearchPaths.value
181+
}
158182
return buildSettings.map{ "\($0) = \($1);" }.joined(separator: " ")
159183
}
160184

@@ -163,6 +187,7 @@ extension SwiftModule {
163187
buildSettings["PRODUCT_MODULE_NAME"] = c99name
164188
buildSettings["OTHER_SWIFT_FLAGS"] = "-DXcode"
165189
buildSettings["MACOSX_DEPLOYMENT_TARGET"] = "'10.10'"
190+
buildSettings["LIBRARY_SEARCH_PATHS"] = "/usr/local/lib"
166191

167192
// prevents Xcode project upgrade warnings
168193
buildSettings["COMBINE_HIDPI_IMAGES"] = "YES"

0 commit comments

Comments
 (0)