mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
Scan for Info.plist lazily
This commit is contained in:
@@ -151,27 +151,21 @@ public class PBXProjGenerator {
|
||||
|
||||
let sourceFiles = try sourceGenerator.getAllSourceFiles(sources: target.sources)
|
||||
|
||||
// find all Info.plist files
|
||||
let infoPlists: [Path] = target.sources.map { spec.basePath + $0.path }.flatMap { (path) -> [Path] in
|
||||
if path.isFile {
|
||||
if path.lastComponent == "Info.plist" {
|
||||
return [path]
|
||||
}
|
||||
} else {
|
||||
if let children = try? path.recursiveChildren() {
|
||||
return children.filter { $0.lastComponent == "Info.plist" }
|
||||
}
|
||||
}
|
||||
return []
|
||||
}
|
||||
var plistPath: Path? = nil
|
||||
var searchForPlist = true
|
||||
|
||||
let configs: [XCBuildConfiguration] = spec.configs.map { config in
|
||||
var buildSettings = spec.getTargetBuildSettings(target: target, config: config)
|
||||
|
||||
// automatically set INFOPLIST_FILE path
|
||||
if let plistPath = infoPlists.first,
|
||||
!spec.targetHasBuildSetting("INFOPLIST_FILE", basePath: spec.basePath, target: target, config: config) {
|
||||
buildSettings["INFOPLIST_FILE"] = plistPath.byRemovingBase(path: spec.basePath)
|
||||
if !spec.targetHasBuildSetting("INFOPLIST_FILE", basePath: spec.basePath, target: target, config: config) {
|
||||
if searchForPlist {
|
||||
plistPath = getInfoPlist(spec, target.sources)
|
||||
searchForPlist = false
|
||||
}
|
||||
if let plistPath = plistPath {
|
||||
buildSettings["INFOPLIST_FILE"] = plistPath.byRemovingBase(path: spec.basePath)
|
||||
}
|
||||
}
|
||||
|
||||
// automatically calculate bundle id
|
||||
@@ -464,6 +458,20 @@ public class PBXProjGenerator {
|
||||
return pbxtarget
|
||||
}
|
||||
|
||||
func getInfoPlist(_ spec: ProjectSpec, _ sources: [TargetSource]) -> Path? {
|
||||
return sources
|
||||
.lazy
|
||||
.map { spec.basePath + $0.path }
|
||||
.flatMap { (path) -> Path? in
|
||||
if path.isFile {
|
||||
return path.lastComponent == "Info.plist" ? path : nil
|
||||
} else {
|
||||
return path.first(where: { $0.lastComponent == "Info.plist" })
|
||||
}
|
||||
}
|
||||
.first
|
||||
}
|
||||
|
||||
func getCarthageBuildPath(platform: Platform) -> String {
|
||||
|
||||
let carthagePath = Path(carthageBuildPath)
|
||||
|
||||
Reference in New Issue
Block a user