From 59b81bf7fc2fbdaa3a3dec6e890df2080ad245f3 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 13 Mar 2025 15:38:17 +0100 Subject: [PATCH 1/2] Expose an API to return the validated sources --- Sources/XcodeGraph/Models/Target.swift | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Sources/XcodeGraph/Models/Target.swift b/Sources/XcodeGraph/Models/Target.swift index 375ab44d..146621cf 100644 --- a/Sources/XcodeGraph/Models/Target.swift +++ b/Sources/XcodeGraph/Models/Target.swift @@ -204,6 +204,7 @@ public struct Target: Equatable, Hashable, Comparable, Codable, Sendable { } } + @available(*, deprecated, renamed: "validatedSources()") /// Returns true if the target supports having sources. public var supportsSources: Bool { switch product { @@ -217,6 +218,27 @@ public struct Target: Equatable, Hashable, Comparable, Codable, Sendable { } } + /// This function validates the sources against other target metadata returning which sources from the list + /// are valid and invalid. + /// - Returns: A list of valid and invalid sources. + public func validatedSources() -> (valid: [SourceFile], invalid: [SourceFile]) { + switch product { + case .stickerPackExtension, .watch2App: + return (valid: [], invalid: sources) + case .bundle: + if isExclusiveTo(.macOS) { + return (valid: sources, invalid: []) + } else { + return ( + valid: sources.filter { $0.path.extension == "metal" }, + invalid: [] + ) + } + default: + return (valid: sources, invalid: []) + } + } + /// Returns true if the target deploys to more then one platform public var isMultiplatform: Bool { supportedPlatforms.count > 1 From c285443621765b6a22a49c761b8f78af20498b1f Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 18 Mar 2025 16:24:03 +0100 Subject: [PATCH 2/2] Mark supportsSources as deprecated --- Sources/XcodeGraph/Models/Target.swift | 27 +++++--------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/Sources/XcodeGraph/Models/Target.swift b/Sources/XcodeGraph/Models/Target.swift index 146621cf..e59deb17 100644 --- a/Sources/XcodeGraph/Models/Target.swift +++ b/Sources/XcodeGraph/Models/Target.swift @@ -204,7 +204,11 @@ public struct Target: Equatable, Hashable, Comparable, Codable, Sendable { } } - @available(*, deprecated, renamed: "validatedSources()") + @available(*, deprecated, message: """ + Whether a target supports sources or not is not as binary decision as we originally assumed and codified in this getter. + Because it's something that depends on other variables, we decided to pull this logic out of tuist/XcodeGraph into tuist/tuist. + If you are interested in having a similar logic in your XcodeGraph-dependent project, you might want to check out tuist/tuist. + """) /// Returns true if the target supports having sources. public var supportsSources: Bool { switch product { @@ -218,27 +222,6 @@ public struct Target: Equatable, Hashable, Comparable, Codable, Sendable { } } - /// This function validates the sources against other target metadata returning which sources from the list - /// are valid and invalid. - /// - Returns: A list of valid and invalid sources. - public func validatedSources() -> (valid: [SourceFile], invalid: [SourceFile]) { - switch product { - case .stickerPackExtension, .watch2App: - return (valid: [], invalid: sources) - case .bundle: - if isExclusiveTo(.macOS) { - return (valid: sources, invalid: []) - } else { - return ( - valid: sources.filter { $0.path.extension == "metal" }, - invalid: [] - ) - } - default: - return (valid: sources, invalid: []) - } - } - /// Returns true if the target deploys to more then one platform public var isMultiplatform: Bool { supportedPlatforms.count > 1