diff --git a/Sources/XcodeProj/Objects/Files/PBXFileSystemSynchronizedBuildFileExceptionSet.swift b/Sources/XcodeProj/Objects/Files/PBXFileSystemSynchronizedBuildFileExceptionSet.swift index 04923f3e5..d2f6336a2 100644 --- a/Sources/XcodeProj/Objects/Files/PBXFileSystemSynchronizedBuildFileExceptionSet.swift +++ b/Sources/XcodeProj/Objects/Files/PBXFileSystemSynchronizedBuildFileExceptionSet.swift @@ -62,7 +62,7 @@ public class PBXFileSystemSynchronizedBuildFileExceptionSet: PBXObject { // MARK: - Equatable override func isEqual(to object: Any?) -> Bool { - guard let rhs = object as? PBXFrameworksBuildPhase else { return false } + guard let rhs = object as? PBXFileSystemSynchronizedBuildFileExceptionSet else { return false } return isEqual(to: rhs) } diff --git a/Sources/XcodeProj/Objects/Files/PBXFileSystemSynchronizedRootGroup.swift b/Sources/XcodeProj/Objects/Files/PBXFileSystemSynchronizedRootGroup.swift index 0d8196837..23da01498 100644 --- a/Sources/XcodeProj/Objects/Files/PBXFileSystemSynchronizedRootGroup.swift +++ b/Sources/XcodeProj/Objects/Files/PBXFileSystemSynchronizedRootGroup.swift @@ -100,7 +100,7 @@ public class PBXFileSystemSynchronizedRootGroup: PBXFileElement { } override func isEqual(to object: Any?) -> Bool { - guard let rhs = object as? PBXFrameworksBuildPhase else { return false } + guard let rhs = object as? PBXFileSystemSynchronizedRootGroup else { return false } return isEqual(to: rhs) } } diff --git a/Sources/XcodeProj/Objects/Targets/PBXTarget.swift b/Sources/XcodeProj/Objects/Targets/PBXTarget.swift index 16c9c9f94..93f102283 100644 --- a/Sources/XcodeProj/Objects/Targets/PBXTarget.swift +++ b/Sources/XcodeProj/Objects/Targets/PBXTarget.swift @@ -181,9 +181,10 @@ public class PBXTarget: PBXContainerItem { packageProductDependencyReferences = packageProductDependencyReferenceStrings.map { objectReferenceRepository.getOrCreate(reference: $0, objects: objects) } - let fileSystemSynchronizedGroupsReferences: [String] = try container.decodeIfPresent(.fileSystemSynchronizedGroups) ?? [] - self.fileSystemSynchronizedGroupsReferences = fileSystemSynchronizedGroupsReferences.map { objectReferenceRepository.getOrCreate(reference: $0, objects: objects) } - + let fileSystemSynchronizedGroupsReferences: [String]? = try container.decodeIfPresent(.fileSystemSynchronizedGroups) + if let fileSystemSynchronizedGroupsReferences = fileSystemSynchronizedGroupsReferences { + self.fileSystemSynchronizedGroupsReferences = fileSystemSynchronizedGroupsReferences.map { objectReferenceRepository.getOrCreate(reference: $0, objects: objects) } + } productType = try container.decodeIfPresent(.productType) try super.init(from: decoder) } diff --git a/Tests/XcodeProjTests/Objects/Files/PBXFileSystemSynchronizedBuildFileExceptionSet+Fixtures.swift b/Tests/XcodeProjTests/Objects/Files/PBXFileSystemSynchronizedBuildFileExceptionSet+Fixtures.swift new file mode 100644 index 000000000..d49b85791 --- /dev/null +++ b/Tests/XcodeProjTests/Objects/Files/PBXFileSystemSynchronizedBuildFileExceptionSet+Fixtures.swift @@ -0,0 +1,13 @@ +import XcodeProj + +extension PBXFileSystemSynchronizedBuildFileExceptionSet { + static func fixture(target: PBXTarget = .fixture(), + membershipExceptions: [String]? = [], + publicHeaders: [String]? = [], + privateHeaders: [String]? = []) -> PBXFileSystemSynchronizedBuildFileExceptionSet { + return PBXFileSystemSynchronizedBuildFileExceptionSet(target: target, + membershipExceptions: membershipExceptions, + publicHeaders: publicHeaders, + privateHeaders: privateHeaders) + } +} diff --git a/Tests/XcodeProjTests/Objects/Files/PBXFileSystemSynchronizedBuildFileExceptionSetTests.swift b/Tests/XcodeProjTests/Objects/Files/PBXFileSystemSynchronizedBuildFileExceptionSetTests.swift new file mode 100644 index 000000000..799edaee3 --- /dev/null +++ b/Tests/XcodeProjTests/Objects/Files/PBXFileSystemSynchronizedBuildFileExceptionSetTests.swift @@ -0,0 +1,29 @@ +import Foundation +import XCTest +@testable import XcodeProj + +final class PBXFileSystemSynchronizedBuildFileExceptionSetTests: XCTestCase { + var target: PBXTarget! + var subject: PBXFileSystemSynchronizedBuildFileExceptionSet! + + override func setUp() { + super.setUp() + target = PBXTarget.fixture() + subject = PBXFileSystemSynchronizedBuildFileExceptionSet.fixture(target: target) + } + + override func tearDown() { + target = nil + subject = nil + super.tearDown() + } + + func test_itHasTheCorrectIsa() { + XCTAssertEqual(PBXFileSystemSynchronizedBuildFileExceptionSet.isa, "PBXFileSystemSynchronizedBuildFileExceptionSet") + } + + func test_equal_returnsTheCorrectValue() { + let another = PBXFileSystemSynchronizedBuildFileExceptionSet.fixture(target: target) + XCTAssertEqual(subject, another) + } +} diff --git a/Tests/XcodeProjTests/Objects/Files/PBXFileSystemSynchronizedRootGroup+Fixtures.swift b/Tests/XcodeProjTests/Objects/Files/PBXFileSystemSynchronizedRootGroup+Fixtures.swift new file mode 100644 index 000000000..7a14963af --- /dev/null +++ b/Tests/XcodeProjTests/Objects/Files/PBXFileSystemSynchronizedRootGroup+Fixtures.swift @@ -0,0 +1,27 @@ +import XcodeProj + +extension PBXFileSystemSynchronizedRootGroup { + static func fixture(sourceTree: PBXSourceTree? = nil, + path: String? = nil, + name: String? = nil, + includeInIndex: Bool? = nil, + usesTabs: Bool? = nil, + indentWidth: UInt? = nil, + tabWidth: UInt? = nil, + wrapsLines: Bool? = nil, + explicitFileTypes: [String: String] = [:], + exceptions: [PBXFileSystemSynchronizedBuildFileExceptionSet] = [], + explicitFolders: [String] = []) -> PBXFileSystemSynchronizedRootGroup { + return PBXFileSystemSynchronizedRootGroup(sourceTree: sourceTree, + path: path, + name: name, + includeInIndex: includeInIndex, + usesTabs: usesTabs, + indentWidth: indentWidth, + tabWidth: tabWidth, + wrapsLines: wrapsLines, + explicitFileTypes: explicitFileTypes, + exceptions: exceptions, + explicitFolders: explicitFolders) + } +} diff --git a/Tests/XcodeProjTests/Objects/Files/PBXFileSystemSynchronizedRootGroupTests.swift b/Tests/XcodeProjTests/Objects/Files/PBXFileSystemSynchronizedRootGroupTests.swift new file mode 100644 index 000000000..21894e0e0 --- /dev/null +++ b/Tests/XcodeProjTests/Objects/Files/PBXFileSystemSynchronizedRootGroupTests.swift @@ -0,0 +1,51 @@ +import Foundation +import XCTest +@testable import XcodeProj + +final class PBXFileSystemSynchronizedRootGroupTests: XCTestCase { + var subject: PBXFileSystemSynchronizedRootGroup! + var target: PBXTarget! + var exception: PBXFileSystemSynchronizedBuildFileExceptionSet! + + override func setUp() { + super.setUp() + target = PBXTarget.fixture() + exception = PBXFileSystemSynchronizedBuildFileExceptionSet.fixture(target: target) + subject = PBXFileSystemSynchronizedRootGroup(sourceTree: .group, + path: "synchronized", + name: "synchronized", + includeInIndex: true, + usesTabs: true, + indentWidth: 2, + tabWidth: 2, + wrapsLines: true, + explicitFileTypes: ["Source.m": "sourcecode.c.objc"], + exceptions: [exception], + explicitFolders: []) + } + + override func tearDown() { + exception = nil + subject = nil + super.tearDown() + } + + func test_itHasTheCorrectIsa() { + XCTAssertEqual(PBXFileSystemSynchronizedRootGroup.isa, "PBXFileSystemSynchronizedRootGroup") + } + + func test_equal_returnsTheCorrectValue() { + let another = PBXFileSystemSynchronizedRootGroup(sourceTree: .group, + path: "synchronized", + name: "synchronized", + includeInIndex: true, + usesTabs: true, + indentWidth: 2, + tabWidth: 2, + wrapsLines: true, + explicitFileTypes: ["Source.m": "sourcecode.c.objc"], + exceptions: [exception], + explicitFolders: []) + XCTAssertEqual(subject, another) + } +}