From 58511de01bb20c125f9d0479d27bf5ab5051c473 Mon Sep 17 00:00:00 2001 From: Paul Feischl Date: Thu, 22 Nov 2018 18:31:19 +0100 Subject: [PATCH 1/5] add check if INFOPLIST build setting is already defined --- Sources/XcodeGenKit/PBXProjGenerator.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index 96c21623a..ab48b96dd 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -793,7 +793,9 @@ public class PBXProjGenerator { } // Set INFOPLIST_FILE - if let info = target.info { + if project.targetHasBuildSetting("INFOPLIST_FILE", target: target, config: config) { + // do not overwrite Info.plist path when already defined + } else if let info = target.info { buildSettings["INFOPLIST_FILE"] = info.path } else if !project.targetHasBuildSetting("INFOPLIST_FILE", target: target, config: config) { if searchForPlist { From 1bfc67448bf212155def376171cfba32a3637b54 Mon Sep 17 00:00:00 2001 From: Paul Feischl Date: Fri, 23 Nov 2018 09:31:28 +0100 Subject: [PATCH 2/5] update ProjectSpec.md --- Docs/ProjectSpec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index ecf64a6a9..54ad3a273 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -171,7 +171,7 @@ Settings are merged in the following order: groups, base, configs. - `FRAMEWORK_SEARCH_PATHS`: If carthage dependencies are used, the platform build path will be added to this setting - `OTHER_LDFLAGS`: See `requiresObjCLinking` below - [ ] **dependencies**: **[[Dependency](#dependency)]** - Dependencies for the target -- [ ] **info**: **[Plist](#plist)** - If defined, this will generate and write an `Info.plist` to the specified path and use it by setting the `INFOPLIST_FILE` build setting for every configuration. The following properties are generated automatically, the rest will have to be provided. +- [ ] **info**: **[Plist](#plist)** - If defined, this will generate and write an `Info.plist` to the specified path and use it by setting the `INFOPLIST_FILE` build setting for every configuration, unless `INFOPLIST_FILE` is already defined in **settings** for this configuration. The following properties are generated automatically, the rest will have to be provided. - `CFBundleIdentifier` - `CFBundleInfoDictionaryVersion` - `CFBundleExecutable` From 5ffeade6b8f9c0050e996edcc193aa9fa8f85d84 Mon Sep 17 00:00:00 2001 From: feischl97 Date: Mon, 26 Nov 2018 11:47:08 +0100 Subject: [PATCH 3/5] add test info does not override info.plist setting --- .../ProjectGeneratorTests.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 3dd7158f2..e20bacf5e 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -882,6 +882,24 @@ class ProjectGeneratorTests: XCTestCase { try expect(NSDictionary(dictionary: expectedInfoPlist).isEqual(to: infoPlist)).beTrue() } + + $0.it("info doesn't override info.plist setting") { + let predefinedPlistPath = "Predefined.plist" + // generate plist + let plist = Plist(path: "Info.plist", attributes: ["UISupportedInterfaceOrientations": ["UIInterfaceOrientationPortrait", "UIInterfaceOrientationLandscapeLeft"]]) + let tempPath = Path.temporary + "info" + // create project with a predefined plist + let project = Project(basePath: tempPath, name: "", targets: [Target(name: "", type: .application, platform: .iOS, settings: Settings(buildSettings: ["INFOPLIST_FILE": predefinedPlistPath]), info: plist)]) + let pbxProject = try project.generatePbxProj() + let writer = FileWriter(project: project) + try writer.writePlists() + + guard let targetConfig = pbxProject.nativeTargets.first?.buildConfigurationList?.buildConfigurations.first else { + throw failure("Couldn't find Target config") + } + // generated plist should not be in buildsettings + try expect(targetConfig.buildSettings["INFOPLIST_FILE"] as? String) == predefinedPlistPath + } } } } From 3461bc2835339f225af8a1b7139c9491d87da99c Mon Sep 17 00:00:00 2001 From: feischl97 Date: Mon, 26 Nov 2018 12:06:30 +0100 Subject: [PATCH 4/5] refactor if --- Sources/XcodeGenKit/PBXProjGenerator.swift | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index ab48b96dd..cfab3bce8 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -792,13 +792,11 @@ public class PBXProjGenerator { buildSettings["CODE_SIGN_ENTITLEMENTS"] = entitlements.path } - // Set INFOPLIST_FILE - if project.targetHasBuildSetting("INFOPLIST_FILE", target: target, config: config) { - // do not overwrite Info.plist path when already defined - } else if let info = target.info { - buildSettings["INFOPLIST_FILE"] = info.path - } else if !project.targetHasBuildSetting("INFOPLIST_FILE", target: target, config: config) { - if searchForPlist { + // Set INFOPLIST_FILE if not defined in settings + if !project.targetHasBuildSetting("INFOPLIST_FILE", target: target, config: config) { + if let info = target.info { + buildSettings["INFOPLIST_FILE"] = info.path + } else if searchForPlist { plistPath = getInfoPlist(target.sources) searchForPlist = false } From 2f1aa2bf89f09e318d8cf592786207d8554a7472 Mon Sep 17 00:00:00 2001 From: feischl97 Date: Mon, 26 Nov 2018 13:14:48 +0100 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d968753..ce46923c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ #### Fixed - Fixed XPC Service package type [#435](https://github.com/yonaskolb/XcodeGen/pull/435) @alvarhansen - Fixed phase ordering for modulemap and static libary header Copy File phases. [402](https://github.com/yonaskolb/XcodeGen/pull/402) @brentleyjones +- Fixed overwriting INFOPLIST_FILE setting with info path [#443](https://github.com/yonaskolb/XcodeGen/pull/443) @feischl97 #### Changed - Changed spelling of build phases to **preBuildPhase** and **postBuildPhase**. [402](https://github.com/yonaskolb/XcodeGen/pull/402) @brentleyjones