Skip to content

Commit e3cbc98

Browse files
fix: allow empty PBXProject.TargetAttributes (#924)
* allow empty TargetAttributes * fix unit tests * fix unit test name
1 parent c68412f commit e3cbc98

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

Package.resolved

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/XcodeProj/Objects/Project/PBXProject.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,7 @@ extension PBXProject: PlistSerializable {
572572
plistTargetAttributes[reference.value] = value
573573
}
574574

575-
if !plistTargetAttributes.isEmpty {
576-
plistAttributes[PBXProject.targetAttributesKey] = .attributeDictionary(plistTargetAttributes)
577-
}
575+
plistAttributes[PBXProject.targetAttributesKey] = .attributeDictionary(plistTargetAttributes)
578576

579577
dictionary["attributes"] = plistAttributes.plist()
580578

Tests/XcodeProjTests/Objects/Project/PBXProjectTests.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ final class PBXProjectTests: XCTestCase {
6666
XCTAssertEqual(attributes, expectedAttributes)
6767
}
6868

69-
func test_plistKeyAndValue_doesntReturnTargetAttributes_when_itsEmpty() throws {
69+
func test_plistKeyAndValue_returnsEmptyTargetAttributes_when_itsEmpty() throws {
7070
// Given
7171
let target = PBXTarget(name: "")
7272
target.reference.fix("app")
@@ -81,14 +81,12 @@ final class PBXProjectTests: XCTestCase {
8181
minimizedProjectReferenceProxies: nil,
8282
mainGroup: PBXGroup())
8383

84-
project.setTargetAttributes(["custom": "abc", "TestTargetID": .targetReference(testTarget)], target: target)
85-
8684
// When
8785
let plist = try project.plistKeyAndValue(proj: PBXProj(), reference: "")
8886

8987
// Then
90-
let attributes: [CommentedString: PlistValue]? = plist.value.dictionary?["TargetAttributes"]?.dictionary
91-
XCTAssertNil(attributes)
88+
let attributes = plist.value.dictionary?["attributes"]?.dictionary?["TargetAttributes"]?.dictionary
89+
XCTAssertEqual(attributes, [:])
9290
}
9391

9492
func test_addLocalSwiftPackage() throws {

0 commit comments

Comments
 (0)