From d1382f18e8dde755d2691895f14a48bd0c3a9b35 Mon Sep 17 00:00:00 2001 From: Eric Rabil Date: Thu, 6 Jan 2022 12:05:23 -0500 Subject: [PATCH 1/2] Use produce name from settings as the reference name if present --- Sources/ProjectSpec/Target.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Sources/ProjectSpec/Target.swift b/Sources/ProjectSpec/Target.swift index 60752f445..f97acf27c 100644 --- a/Sources/ProjectSpec/Target.swift +++ b/Sources/ProjectSpec/Target.swift @@ -173,18 +173,23 @@ extension Target { let newTargetName = platformPrefix + targetName + platformSuffix var settings = platformTarget["settings"] as? JSONDictionary ?? [:] + var newProductName: String? if settings["configs"] != nil || settings["groups"] != nil || settings["base"] != nil { var base = settings["base"] as? JSONDictionary ?? [:] - if base["PRODUCT_NAME"] == nil { + if let baseProductName = base["PRODUCT_NAME"] as? String { + newProductName = baseProductName + } else { base["PRODUCT_NAME"] = targetName } settings["base"] = base } else { - if settings["PRODUCT_NAME"] == nil { + if let productName = settings["PRODUCT_NAME"] as? String { + newProductName = productName + } else { settings["PRODUCT_NAME"] = targetName } } - platformTarget["productName"] = targetName + platformTarget["productName"] = newProductName ?? targetName platformTarget["settings"] = settings if let deploymentTargets = target["deploymentTarget"] as? [String: Any] { platformTarget["deploymentTarget"] = deploymentTargets[platform] From 52f8206325a98790dfc4dd61ae7879a0e7ca746b Mon Sep 17 00:00:00 2001 From: Eric Rabil Date: Thu, 6 Jan 2022 12:10:12 -0500 Subject: [PATCH 2/2] Place productName override behind productNameFromSettings --- Sources/ProjectSpec/Target.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ProjectSpec/Target.swift b/Sources/ProjectSpec/Target.swift index f97acf27c..39eb820d4 100644 --- a/Sources/ProjectSpec/Target.swift +++ b/Sources/ProjectSpec/Target.swift @@ -189,7 +189,7 @@ extension Target { settings["PRODUCT_NAME"] = targetName } } - platformTarget["productName"] = newProductName ?? targetName + platformTarget["productName"] = ((platformTarget["productNameFromSettings"] as? Bool == true) ? newProductName : nil) ?? targetName platformTarget["settings"] = settings if let deploymentTargets = target["deploymentTarget"] as? [String: Any] { platformTarget["deploymentTarget"] = deploymentTargets[platform]