-
-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Support for Build Carbon Resources Build Phase
Some macOS apps still build legacy Carbon resources. Fortunately the Xcode project file models this in the same way as the abstract PBXBuildPhase so implementation of the build phase is as easy as adding a subclass, updating the BuildPhase enum, updating PBXProj, and adding decoding/encoding support. In addition to updating the tests, verified xcproj correctly round trips a project with this build phase.
- Loading branch information
1 parent
e10f90e
commit fb7c56b
Showing
10 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Foundation | ||
|
||
/// This is the element for the Build Carbon Resources build phase. | ||
final public class PBXRezBuildPhase: PBXBuildPhase { | ||
|
||
public override var buildPhase: BuildPhase { | ||
return .carbonResources | ||
} | ||
|
||
public static func == (lhs: PBXRezBuildPhase, | ||
rhs: PBXRezBuildPhase) -> Bool { | ||
return lhs.reference == rhs.reference && | ||
lhs.buildActionMask == rhs.buildActionMask && | ||
lhs.files == rhs.files && | ||
lhs.runOnlyForDeploymentPostprocessing == rhs.runOnlyForDeploymentPostprocessing | ||
} | ||
} | ||
|
||
// MARK: - PBXRezBuildPhase Extension (PlistSerializable) | ||
|
||
extension PBXRezBuildPhase: PlistSerializable { | ||
|
||
func plistKeyAndValue(proj: PBXProj) -> (key: CommentedString, value: PlistValue) { | ||
var dictionary: [CommentedString: PlistValue] = plistValues(proj: proj) | ||
dictionary["isa"] = .string(CommentedString(PBXRezBuildPhase.isa)) | ||
return (key: CommentedString(self.reference, comment: "Rez"), value: .dictionary(dictionary)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Foundation | ||
import XCTest | ||
import xcproj | ||
|
||
final class PBXRezBuildPhaseSpec: XCTestCase { | ||
|
||
var subject: PBXRezBuildPhase! | ||
|
||
override func setUp() { | ||
super.setUp() | ||
subject = PBXRezBuildPhase(reference: "ref", | ||
files: ["123"], | ||
runOnlyForDeploymentPostprocessing: 0) | ||
} | ||
|
||
func test_init_initializesTheBuildPhaseWithTheRightValues() { | ||
XCTAssertEqual(subject.reference, "ref") | ||
XCTAssertEqual(subject.files, ["123"]) | ||
XCTAssertEqual(subject.runOnlyForDeploymentPostprocessing, 0) | ||
} | ||
|
||
func test_isa_returnsTheCorrectValue() { | ||
XCTAssertEqual(PBXRezBuildPhase.isa, "PBXRezBuildPhase") | ||
} | ||
|
||
func test_equals_returnsTheCorrectValue() { | ||
let another = PBXResourcesBuildPhase(reference: "ref", | ||
files: ["123"], | ||
runOnlyForDeploymentPostprocessing: 0) | ||
XCTAssertEqual(subject, another) | ||
} | ||
} |