Skip to content

Commit

Permalink
Fix Writing of showEnvVarsInLog
Browse files Browse the repository at this point in the history
Xcode writes showEnvVarsInLog to the pbxproj file if it’s set to false. If it’s true it’s omitted. Update xcproj to use the same behavior to eliminate diffs when round tripping Xcode projects.

This requires defaulting to true when decoding the project file if the key is omitted. I also updated the default parameter in the initializer to true for good measure.
  • Loading branch information
briantkelley committed Mar 7, 2018
1 parent ee94af8 commit 599aa16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

### Fixed
- `PBXObject.isEqual(to:)` overrides correctly call super https://github.com/xcodeswift/xcproj/pull/239 by @briantkelley
- Writes showEnvVarsInLog only when false https://github.com/xcodeswift/xcproj/pull/240 by @briantkelley

## 4.1.0

Expand Down
9 changes: 6 additions & 3 deletions Sources/xcproj/PBXShellScriptBuildPhase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final public class PBXShellScriptBuildPhase: PBXBuildPhase {
shellScript: String? = nil,
buildActionMask: UInt = defaultBuildActionMask,
runOnlyForDeploymentPostprocessing: Bool = false,
showEnvVarsInLog: Bool = false) {
showEnvVarsInLog: Bool = true) {
self.name = name
self.inputPaths = inputPaths
self.outputPaths = outputPaths
Expand Down Expand Up @@ -76,7 +76,7 @@ final public class PBXShellScriptBuildPhase: PBXBuildPhase {
self.outputPaths = (try container.decodeIfPresent(.outputPaths)) ?? []
self.shellPath = try container.decodeIfPresent(.shellPath)
self.shellScript = try container.decodeIfPresent(.shellScript)
self.showEnvVarsInLog = try container.decodeIntBool(.showEnvVarsInLog)
self.showEnvVarsInLog = try container.decodeIntBoolIfPresent(.showEnvVarsInLog) ?? true
try super.init(from: decoder)
}

Expand Down Expand Up @@ -117,7 +117,10 @@ extension PBXShellScriptBuildPhase: PlistSerializable {
if let shellScript = shellScript {
dictionary["shellScript"] = .string(CommentedString(shellScript))
}
dictionary["showEnvVarsInLog"] = .string(CommentedString("\(showEnvVarsInLog.int)"))
if !showEnvVarsInLog {
// Xcode only writes this key if it's set to false; default is true and is omitted
dictionary["showEnvVarsInLog"] = .string(CommentedString("\(showEnvVarsInLog.int)"))
}
return (key: CommentedString(reference, comment: self.name ?? "ShellScript"), value: .dictionary(dictionary))
}

Expand Down

0 comments on commit 599aa16

Please sign in to comment.