Skip to content

Commit

Permalink
Merge pull request #443 from feischl97/fix-issue-440
Browse files Browse the repository at this point in the history
Don't overwrite INFOPLIST_FILE setting with info path
  • Loading branch information
yonaskolb authored Dec 1, 2018
2 parents 1538b4d + 281a124 commit 1b9dadb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Docs/ProjectSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
10 changes: 5 additions & 5 deletions Sources/XcodeGenKit/PBXProjGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
18 changes: 18 additions & 0 deletions Tests/XcodeGenKitTests/ProjectGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}

0 comments on commit 1b9dadb

Please sign in to comment.