diff --git a/CHANGELOG.md b/CHANGELOG.md index 09954c9d..5590ebb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ #### Changed - Changed spelling of build phases to **preBuildPhase** and **postBuildPhase**. [402](https://github.com/yonaskolb/XcodeGen/pull/402) @brentleyjones - **BREAKING** Moved generation to a specific subcommand `xcodegen generate`. If not specifying any arguments `xcodegen` will still work [#437](https://github.com/yonaskolb/XcodeGen/pull/437) @yonaskolb +- If `INFOPLIST_FILE` has been set on a target, then an `info` path won't ovewrite it [#443](https://github.com/yonaskolb/XcodeGen/pull/443) @feischl97 ## 2.0.0 diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index ecf64a6a..54ad3a27 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` diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index 96c21623..cfab3bce 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -792,11 +792,11 @@ public class PBXProjGenerator { buildSettings["CODE_SIGN_ENTITLEMENTS"] = entitlements.path } - // Set INFOPLIST_FILE - 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 } diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 3dd7158f..e20bacf5 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 + } } } }