Skip to content
This repository was archived by the owner on Feb 26, 2026. It is now read-only.

Commit 36c3b19

Browse files
authored
fix: framework not found when name needs to be sanitized (#129)
1 parent f796ad4 commit 36c3b19

3 files changed

Lines changed: 55 additions & 7 deletions

File tree

Sources/XcodeGraphMapper/Mappers/Graph/XcodeGraphMapper.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ public struct XcodeGraphMapper: XcodeGraphMapping {
208208
}
209209
let projectNativeTargets: [String: ProjectNativeTarget] = xcodeProjects.reduce(into: [:]) { acc, xcodeProject in
210210
for nativeTarget in xcodeProject.pbxproj.nativeTargets {
211-
acc[nativeTarget.name] = ProjectNativeTarget(
211+
let name = Target.sanitizedProductNameFrom(
212+
targetName: nativeTarget.name
213+
)
214+
acc[name] = ProjectNativeTarget(
212215
nativeTarget: nativeTarget,
213216
project: xcodeProject
214217
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import XcodeProj
22

33
/// Model representing a `PBXNativeTarget` in a give `XcodeProj`
4-
struct ProjectNativeTarget {
4+
struct ProjectNativeTarget: Equatable {
55
let nativeTarget: PBXNativeTarget
66
let project: XcodeProj
77
}

Tests/XcodeGraphMapperTests/MapperTests/Graph/XcodeGraphMapperTests.swift

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,56 @@ struct XcodeGraphMapperTests {
6262
#expect(graph.workspace.name == "Workspace")
6363
}
6464

65+
@Test("Maps a project with sanitizable target names")
66+
func testProjectWithSanitizableTargetNames() async throws {
67+
// Given
68+
let pbxProj = PBXProj()
69+
70+
let xcodeProj = try await XcodeProj.test(
71+
projectName: "SingleProject",
72+
pbxProj: pbxProj
73+
)
74+
75+
let projectMapper = MockPBXProjectMapping()
76+
given(projectMapper)
77+
.map(
78+
xcodeProj: .any,
79+
projectNativeTargets: .any
80+
)
81+
.willReturn(
82+
.test()
83+
)
84+
85+
// Add a single target to the project
86+
try PBXNativeTarget.test(
87+
name: "App-With-Dash",
88+
productType: .application
89+
)
90+
.add(to: pbxProj)
91+
.add(to: pbxProj.rootObject)
92+
93+
try xcodeProj.write(path: xcodeProj.path!)
94+
let mapper = XcodeGraphMapper(
95+
projectMapper: projectMapper
96+
)
97+
// When
98+
_ = try await mapper.buildGraph(from: .project(xcodeProj))
99+
100+
// Then
101+
verify(projectMapper)
102+
.map(
103+
xcodeProj: .any,
104+
projectNativeTargets: .matching(
105+
{
106+
$0.keys.map { $0 } == [
107+
"App_With_Dash",
108+
]
109+
}
110+
)
111+
)
112+
.called(1)
113+
}
114+
65115
@Test("Maps a workspace with multiple projects into a single graph")
66116
func testWorkspaceGraphMultipleProjects() async throws {
67117
// Given
@@ -359,10 +409,5 @@ struct XcodeGraphMapperTests {
359409
],
360410
]
361411
)
362-
// // Verify dependencies are mapped
363-
// let targetDep = GraphDependency.target(name: "AFramework", path: xcodeProj.srcPath)
364-
// let expectedDependency = try #require(graph.dependencies.first?.value)
365-
366-
// #expect(expectedDependency == [targetDep])
367412
}
368413
}

0 commit comments

Comments
 (0)