Skip to content

Commit 49e382a

Browse files
authored
fix: Allow static frameworks to support resources (#451)
1 parent 896a3b8 commit 49e382a

24 files changed

+118
-107
lines changed

Sources/XcodeGraph/Models/Target.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,12 @@ public struct Target: Equatable, Hashable, Comparable, Codable, Sendable {
213213
}
214214
}
215215

216+
/// Returns true if the target supports having sources.
216217
@available(*, deprecated, message: """
217218
Whether a target supports sources or not is not as binary decision as we originally assumed and codified in this getter.
218219
Because it's something that depends on other variables, we decided to pull this logic out of tuist/XcodeGraph into tuist/tuist.
219220
If you are interested in having a similar logic in your XcodeGraph-dependent project, you might want to check out tuist/tuist.
220221
""")
221-
/// Returns true if the target supports having sources.
222222
public var supportsSources: Bool {
223223
switch product {
224224
case .stickerPackExtension, .watch2App:
@@ -241,6 +241,7 @@ public struct Target: Equatable, Hashable, Comparable, Codable, Sendable {
241241
switch product {
242242
case .app,
243243
.framework,
244+
.staticFramework,
244245
.unitTests,
245246
.uiTests,
246247
.bundle,
@@ -259,7 +260,6 @@ public struct Target: Equatable, Hashable, Comparable, Codable, Sendable {
259260
.macro,
260261
.dynamicLibrary,
261262
.staticLibrary,
262-
.staticFramework,
263263
.xpc:
264264
return false
265265
}

Sources/XcodeGraph/Models/Workspace.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ extension Workspace {
103103
let allSchemes = schemes + projects.flatMap(\.schemes)
104104
var resultTargets = Set<TargetReference>()
105105

106-
allSchemes.forEach { scheme in
106+
for scheme in allSchemes {
107107
// try to add code coverage targets only if code coverage is enabled
108-
guard let testAction = scheme.testAction, testAction.coverage else { return }
108+
guard let testAction = scheme.testAction, testAction.coverage else { continue }
109109

110110
let schemeCoverageTargets = testAction.codeCoverageTargets
111111

Tests/XcodeGraphMapperTests/MapperTests/Graph/XcodeGraphMapperTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct XcodeGraphMapperTests {
1212
private let fileSystem = FileSystem()
1313

1414
@Test("Maps a single project into a workspace graph")
15-
func testSingleProjectGraph() async throws {
15+
func singleProjectGraph() async throws {
1616
// Given
1717
let pbxProj = PBXProj()
1818
let debug: XCBuildConfiguration = .testDebug().add(to: pbxProj)
@@ -63,7 +63,7 @@ struct XcodeGraphMapperTests {
6363
}
6464

6565
@Test("Maps a project with sanitizable target names")
66-
func testProjectWithSanitizableTargetNames() async throws {
66+
func projectWithSanitizableTargetNames() async throws {
6767
// Given
6868
let pbxProj = PBXProj()
6969

@@ -113,7 +113,7 @@ struct XcodeGraphMapperTests {
113113
}
114114

115115
@Test("Maps a project with custom target product names")
116-
func testProjectWithCustomTargetProductNames() async throws {
116+
func projectWithCustomTargetProductNames() async throws {
117117
// Given
118118
let pbxProj = PBXProj()
119119

@@ -164,7 +164,7 @@ struct XcodeGraphMapperTests {
164164
}
165165

166166
@Test("Maps a workspace with multiple projects into a single graph")
167-
func testWorkspaceGraphMultipleProjects() async throws {
167+
func workspaceGraphMultipleProjects() async throws {
168168
// Given
169169
let pbxProjA = PBXProj()
170170
let pbxProjB = PBXProj()
@@ -254,7 +254,7 @@ struct XcodeGraphMapperTests {
254254
}
255255

256256
@Test("Maps a workspace with multiple projects in different directories into a single graph")
257-
func testWorkspaceGraphMultipleProjectsInDifferentDirectories() async throws {
257+
func workspaceGraphMultipleProjectsInDifferentDirectories() async throws {
258258
// Given
259259
//
260260
// A project structure like this:
@@ -329,7 +329,7 @@ struct XcodeGraphMapperTests {
329329
}
330330

331331
@Test("Maps a project graph with dependencies between targets")
332-
func testGraphWithDependencies() async throws {
332+
func graphWithDependencies() async throws {
333333
// Given
334334
let pbxProj = PBXProj()
335335
let debug: XCBuildConfiguration = .testDebug().add(to: pbxProj)
@@ -395,7 +395,7 @@ struct XcodeGraphMapperTests {
395395
}
396396

397397
@Test("Maps a project graph with local packages")
398-
func testGraphWithLocalPackages() async throws {
398+
func graphWithLocalPackages() async throws {
399399
// Given
400400
let pbxProj = PBXProj()
401401
let debug: XCBuildConfiguration = .testDebug().add(to: pbxProj)

Tests/XcodeGraphMapperTests/MapperTests/Package/PackageMapperTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct PackageMapperTests: Sendable {
99
private let fileSystem = FileSystem()
1010

1111
@Test
12-
func test_map_package() async throws {
12+
func map_package() async throws {
1313
try await fileSystem.runInTemporaryDirectory(prefix: "PackageMapperTests") { path in
1414
// Given
1515
let subject = PackageMapper()

Tests/XcodeGraphMapperTests/MapperTests/Package/XCPackageMapperTests.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct XCPackageMapperTests {
1313
}
1414

1515
@Test("Maps a remote package with a valid URL and up-to-next-major requirement")
16-
func testMapPackageWithValidURL() async throws {
16+
func mapPackageWithValidURL() async throws {
1717
// Given
1818
let package = XCRemoteSwiftPackageReference(
1919
repositoryURL: "https://github.com/example/package.git",
@@ -34,7 +34,7 @@ struct XCPackageMapperTests {
3434
}
3535

3636
@Test("Maps an up-to-next-major version requirement correctly")
37-
func testMapRequirementUpToNextMajor() async throws {
37+
func mapRequirementUpToNextMajor() async throws {
3838
// Given
3939
let package = XCRemoteSwiftPackageReference(
4040
repositoryURL: "https://github.com/example/package.git",
@@ -48,7 +48,7 @@ struct XCPackageMapperTests {
4848
}
4949

5050
@Test("Maps an up-to-next-minor version requirement correctly")
51-
func testMapRequirementUpToNextMinor() async throws {
51+
func mapRequirementUpToNextMinor() async throws {
5252
// Given
5353
let package = XCRemoteSwiftPackageReference(
5454
repositoryURL: "https://github.com/example/package.git",
@@ -63,7 +63,7 @@ struct XCPackageMapperTests {
6363
}
6464

6565
@Test("Maps an exact version requirement correctly")
66-
func testMapRequirementExact() async throws {
66+
func mapRequirementExact() async throws {
6767
// Given
6868
let package = XCRemoteSwiftPackageReference(
6969
repositoryURL: "https://github.com/example/package.git",
@@ -78,7 +78,7 @@ struct XCPackageMapperTests {
7878
}
7979

8080
@Test("Maps a range version requirement correctly")
81-
func testMapRequirementRange() async throws {
81+
func mapRequirementRange() async throws {
8282
// Given
8383
let package = XCRemoteSwiftPackageReference(
8484
repositoryURL: "https://github.com/example/package.git",
@@ -93,7 +93,7 @@ struct XCPackageMapperTests {
9393
}
9494

9595
@Test("Maps a branch-based version requirement correctly")
96-
func testMapRequirementBranch() async throws {
96+
func mapRequirementBranch() async throws {
9797
// Given
9898
let package = XCRemoteSwiftPackageReference(
9999
repositoryURL: "https://github.com/example/package.git",
@@ -108,7 +108,7 @@ struct XCPackageMapperTests {
108108
}
109109

110110
@Test("Maps a revision-based version requirement correctly")
111-
func testMapRequirementRevision() async throws {
111+
func mapRequirementRevision() async throws {
112112
// Given
113113
let package = XCRemoteSwiftPackageReference(
114114
repositoryURL: "https://github.com/example/package.git",
@@ -123,7 +123,7 @@ struct XCPackageMapperTests {
123123
}
124124

125125
@Test("Maps a missing version requirement to up-to-next-major(0.0.0)")
126-
func testMapRequirementNoVersionRequirement() async throws {
126+
func mapRequirementNoVersionRequirement() async throws {
127127
// Given
128128
let package = XCRemoteSwiftPackageReference(
129129
repositoryURL: "https://github.com/example/package.git",
@@ -138,7 +138,7 @@ struct XCPackageMapperTests {
138138
}
139139

140140
@Test("Maps a local package reference correctly")
141-
func testMapLocalPackage() async throws {
141+
func mapLocalPackage() async throws {
142142
// Given
143143
let xcodeProj = try await XcodeProj.test()
144144
let localPackage = XCLocalSwiftPackageReference(relativePath: "Packages/Example")
@@ -154,7 +154,7 @@ struct XCPackageMapperTests {
154154
}
155155

156156
@Test("Throws an error if remote package has no repository URL")
157-
func testMapPackageWithoutURL() async throws {
157+
func mapPackageWithoutURL() async throws {
158158
// Given
159159
let package = XCRemoteSwiftPackageReference(
160160
repositoryURL: "",

Tests/XcodeGraphMapperTests/MapperTests/Phases/PBXCopyFilesBuildPhaseMapperTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import XcodeProj
66
@Suite
77
struct PBXCopyFilesBuildPhaseMapperTests {
88
@Test("Maps copy files actions, verifying code-sign-on-copy attributes")
9-
func testMapCopyFiles() async throws {
9+
func mapCopyFiles() async throws {
1010
// Given
1111
let xcodeProj = try await XcodeProj.test()
1212
let pbxProj = xcodeProj.pbxproj
@@ -64,7 +64,7 @@ struct PBXCopyFilesBuildPhaseMapperTests {
6464
}
6565

6666
@Test("Maps copy files actions with a synchronized group")
67-
func testMapCopyFilesWithSynchronizedGroup() async throws {
67+
func mapCopyFilesWithSynchronizedGroup() async throws {
6868
// Given
6969
let xcodeProj = try await XcodeProj.test(
7070
path: "/tmp/TestProject/Project.xcodeproj"

Tests/XcodeGraphMapperTests/MapperTests/Phases/PBXCoreDataModelsBuildPhaseMapperTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import XcodeProj
66
@Suite
77
struct PBXCoreDataModelsBuildPhaseMapperTests {
88
@Test("Maps CoreData models from version groups within resources phase")
9-
func testMapCoreDataModels() async throws {
9+
func mapCoreDataModels() async throws {
1010
// Given
1111
let xcodeProj = try await XcodeProj.test()
1212
let pbxProj = xcodeProj.pbxproj

Tests/XcodeGraphMapperTests/MapperTests/Phases/PBXFrameworksBuildPhaseMapperTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import XcodeProj
88
@Suite
99
struct PBXFrameworksBuildPhaseMapperTests {
1010
@Test("Maps frameworks from frameworks phase")
11-
func testMapFrameworks() async throws {
11+
func mapFrameworks() async throws {
1212
// Given
1313
let xcodeProj = try await XcodeProj.test()
1414
let pbxProj = xcodeProj.pbxproj
@@ -139,7 +139,7 @@ struct PBXFrameworksBuildPhaseMapperTests {
139139
}
140140

141141
@Test("Maps SDK frameworks")
142-
func testMapSDKFrameworks() async throws {
142+
func mapSDKFrameworks() async throws {
143143
// Given
144144
let xcodeProj = try await XcodeProj.test()
145145
let pbxProj = xcodeProj.pbxproj

Tests/XcodeGraphMapperTests/MapperTests/Phases/PBXHeadersBuildPhaseMapperTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import XcodeProj
66
@Suite
77
struct PBXHeadersBuildPhaseMapperTests {
88
@Test("Maps public, private, and project headers from headers phase")
9-
func testMapHeaders() async throws {
9+
func mapHeaders() async throws {
1010
// Given
1111
let xcodeProj = try await XcodeProj.test()
1212
let pbxProj = xcodeProj.pbxproj

Tests/XcodeGraphMapperTests/MapperTests/Phases/PBXResourcesBuildPhaseMapperTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import XcodeProj
66
@Suite
77
struct PBXResourcesBuildPhaseMapperTests {
88
@Test("Maps resources (like xcassets) from resources phase")
9-
func testMapResources() async throws {
9+
func mapResources() async throws {
1010
// Given
1111
let xcodeProj = try await XcodeProj.test()
1212
let pbxProj = xcodeProj.pbxproj
@@ -48,7 +48,7 @@ struct PBXResourcesBuildPhaseMapperTests {
4848
}
4949

5050
@Test("Maps resource bundle target dependencies from resources phase")
51-
func testMapResourceBundleTargets() async throws {
51+
func mapResourceBundleTargets() async throws {
5252
// Given
5353
let xcodeProj = try await XcodeProj.test()
5454
let pbxProj = xcodeProj.pbxproj
@@ -127,7 +127,7 @@ struct PBXResourcesBuildPhaseMapperTests {
127127
}
128128

129129
@Test("Maps localized variant groups from resources")
130-
func testMapVariantGroup() async throws {
130+
func mapVariantGroup() async throws {
131131
// Given
132132
let xcodeProj = try await XcodeProj.test()
133133
let pbxProj = xcodeProj.pbxproj

0 commit comments

Comments
 (0)