Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Sources/XcodeGraphMapper/Mappers/Graph/XcodeGraphMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ public struct XcodeGraphMapper: XcodeGraphMapping {
try XcodeProj(pathString: $0.pathString)
}
let projectNativeTargets: [String: ProjectNativeTarget] = xcodeProjects.reduce(into: [:]) { acc, xcodeProject in
for nativeTarget in xcodeProject.pbxproj.nativeTargets {
for nativeTarget in xcodeProject.pbxproj.nativeTargets.sorted(by: { $0.name > $1.name }) {
let name = Target.sanitizedProductNameFrom(
targetName: nativeTarget.name
targetName: nativeTarget.productName ?? nativeTarget.name
)
acc[name] = ProjectNativeTarget(
nativeTarget: nativeTarget,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,57 @@ struct XcodeGraphMapperTests {
.called(1)
}

@Test("Maps a project with custom target product names")
func testProjectWithCustomTargetProductNames() async throws {
// Given
let pbxProj = PBXProj()

let xcodeProj = try await XcodeProj.test(
projectName: "SingleProject",
pbxProj: pbxProj
)

let projectMapper = MockPBXProjectMapping()
given(projectMapper)
.map(
xcodeProj: .any,
projectNativeTargets: .any
)
.willReturn(
.test()
)

// Add a single target to the project
try PBXNativeTarget.test(
name: "Alamofire-tvOS",
productName: "Alamofire",
productType: .application
)
.add(to: pbxProj)
.add(to: pbxProj.rootObject)

try xcodeProj.write(path: xcodeProj.path!)
let mapper = XcodeGraphMapper(
projectMapper: projectMapper
)
// When
_ = try await mapper.buildGraph(from: .project(xcodeProj))

// Then
verify(projectMapper)
.map(
xcodeProj: .any,
projectNativeTargets: .matching(
{
$0.keys.map { $0 } == [
"Alamofire",
]
}
)
)
.called(1)
}

@Test("Maps a workspace with multiple projects into a single graph")
func testWorkspaceGraphMultipleProjects() async throws {
// Given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extension PBXNativeTarget {
],
dependencies: [PBXTargetDependency] = [],
productInstallPath: String? = nil,
productName: String? = nil,
productType: PBXProductType = .application,
product: PBXFileReference? = PBXFileReference.test(
sourceTree: .buildProductsDir,
Expand All @@ -28,7 +29,7 @@ extension PBXNativeTarget {
buildRules: buildRules,
dependencies: dependencies,
productInstallPath: productInstallPath,
productName: name,
productName: productName ?? name,
product: product,
productType: productType
)
Expand Down