From 9305ef8cbb1f8c92b0309ff4b260d573c311d474 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 20 Sep 2025 10:03:56 +0200 Subject: [PATCH 1/8] Add exceptions to buildable folders --- Package.resolved | 10 +++++----- .../XcodeGraph/Models/BuildableFolder.swift | 6 +++++- .../Models/BuildableFolderException.swift | 19 +++++++++++++++++++ .../Models/BuildableFolderExceptions.swift | 19 +++++++++++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 Sources/XcodeGraph/Models/BuildableFolderException.swift create mode 100644 Sources/XcodeGraph/Models/BuildableFolderExceptions.swift diff --git a/Package.resolved b/Package.resolved index 5b52b851..cb542683 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "3723bf697fd3c9deb411523eef2023627c93557d8d2729d3e438c927a4be3b5c", + "originHash" : "88fcdf8451554503ef74eb5a6e07f1c3b4af720431bfc6f6ba1d606475e66ced", "pins" : [ { "identity" : "aexml", @@ -33,8 +33,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/tuist/FileSystem.git", "state" : { - "revision" : "d2f49d5a9f8ada3b6e1a2bc4254d715b214d5753", - "version" : "0.11.8" + "revision" : "1e8890203abfc0dcd887b49ec5e91ea75b394495", + "version" : "0.11.23" } }, { @@ -42,8 +42,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/p-x9/MachOKit", "state" : { - "revision" : "5a09d8ad1be010bcd58d8a39554480b19e0a45e1", - "version" : "0.37.0" + "revision" : "fc1f2646220b3ce9db2e415b6b8848f5a89ed865", + "version" : "0.39.0" } }, { diff --git a/Sources/XcodeGraph/Models/BuildableFolder.swift b/Sources/XcodeGraph/Models/BuildableFolder.swift index 7c83979c..34ce4be4 100644 --- a/Sources/XcodeGraph/Models/BuildableFolder.swift +++ b/Sources/XcodeGraph/Models/BuildableFolder.swift @@ -8,9 +8,13 @@ public struct BuildableFolder: Sendable, Codable, Equatable, Hashable { /// The absolute path to the buildable folder. public var path: AbsolutePath + /// Exceptions to the buildable folder. + public var exceptions: BuildableFolderExceptions + /// Creates an instance of buildable folder. /// - Parameter path: Absolute path to the buildable folder. - public init(path: AbsolutePath) { + public init(path: AbsolutePath, exceptions: BuildableFolderExceptions) { self.path = path + self.exceptions = exceptions } } diff --git a/Sources/XcodeGraph/Models/BuildableFolderException.swift b/Sources/XcodeGraph/Models/BuildableFolderException.swift new file mode 100644 index 00000000..9c455524 --- /dev/null +++ b/Sources/XcodeGraph/Models/BuildableFolderException.swift @@ -0,0 +1,19 @@ +import Path + +/// Represents exceptions for a buildable folder, such as files to exclude or specific compiler flags to apply. +public struct BuildableFolderException: Sendable, Codable, Equatable, Hashable { + /// A list of absolute paths to files excluded from the buildable folder. + public var exclued: [AbsolutePath] + + /// A dictionary mapping files (referenced by their absolute path) to the compiler flags to apply. + public var compilerFlags: [AbsolutePath: String] + + /// Creates a new exception for a buildable folder. + /// - Parameters: + /// - exclued: An array of absolute paths to files that should be excluded from the buildable folder. + /// - compilerFlags: A dictionary mapping absolute file paths to specific compiler flags to apply to those files. + public init(exclued: [AbsolutePath], compilerFlags: [AbsolutePath: String]) { + self.exclued = exclued + self.compilerFlags = compilerFlags + } +} diff --git a/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift b/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift new file mode 100644 index 00000000..c948ffb9 --- /dev/null +++ b/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift @@ -0,0 +1,19 @@ +import Path + +/// PBXFileSystemSynchronizedRootGroup have a one-to-many relationship with PBXFileSystemSynchronizedBuildFileExceptionSet +/// through .exceptions. Exceptions are used to exclude files and override conffigurations. +public struct BuildableFolderExceptions: Sendable, Codable, Equatable, Hashable, ExpressibleByArrayLiteral { + /// A list with all the exceptions. + public var exceptions: [BuildableFolderException] + + /// Create a group of exceptions to exclude files from your group or change the configuration of some of them. + /// - Parameter exceptions: The list of exceptions. + /// - Returns: An instance containing all the exceptions. + public init(arrayLiteral elements: BuildableFolderException...) { + exceptions = elements + } + + private init(exceptions: [BuildableFolderException]) { + self.exceptions = exceptions + } +} From dbc1dc35b92be18fb7b0a53143d76c34f06c4125 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 20 Sep 2025 10:18:46 +0200 Subject: [PATCH 2/8] Fix typo --- Sources/XcodeGraph/Models/BuildableFolderException.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/XcodeGraph/Models/BuildableFolderException.swift b/Sources/XcodeGraph/Models/BuildableFolderException.swift index 9c455524..4fb3b89b 100644 --- a/Sources/XcodeGraph/Models/BuildableFolderException.swift +++ b/Sources/XcodeGraph/Models/BuildableFolderException.swift @@ -3,17 +3,17 @@ import Path /// Represents exceptions for a buildable folder, such as files to exclude or specific compiler flags to apply. public struct BuildableFolderException: Sendable, Codable, Equatable, Hashable { /// A list of absolute paths to files excluded from the buildable folder. - public var exclued: [AbsolutePath] + public var excluded: [AbsolutePath] /// A dictionary mapping files (referenced by their absolute path) to the compiler flags to apply. public var compilerFlags: [AbsolutePath: String] /// Creates a new exception for a buildable folder. /// - Parameters: - /// - exclued: An array of absolute paths to files that should be excluded from the buildable folder. + /// - excluded: An array of absolute paths to files that should be excluded from the buildable folder. /// - compilerFlags: A dictionary mapping absolute file paths to specific compiler flags to apply to those files. - public init(exclued: [AbsolutePath], compilerFlags: [AbsolutePath: String]) { - self.exclued = exclued + public init(excluded: [AbsolutePath], compilerFlags: [AbsolutePath: String]) { + self.excluded = excluded self.compilerFlags = compilerFlags } } From dd3d08e9e1c1b8c5d0577743ef935269874cfc12 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 20 Sep 2025 10:57:45 +0200 Subject: [PATCH 3/8] Make init public --- Sources/XcodeGraph/Models/BuildableFolderExceptions.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift b/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift index c948ffb9..acde8df0 100644 --- a/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift +++ b/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift @@ -13,7 +13,7 @@ public struct BuildableFolderExceptions: Sendable, Codable, Equatable, Hashable, exceptions = elements } - private init(exceptions: [BuildableFolderException]) { + public init(exceptions: [BuildableFolderException]) { self.exceptions = exceptions } } From 85e77585d688ea5fcebc129bff1cb44141d7d852 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 20 Sep 2025 11:10:00 +0200 Subject: [PATCH 4/8] Make exceptions a sequence --- Sources/XcodeGraph/Models/BuildableFolderExceptions.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift b/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift index acde8df0..076c85a1 100644 --- a/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift +++ b/Sources/XcodeGraph/Models/BuildableFolderExceptions.swift @@ -2,7 +2,7 @@ import Path /// PBXFileSystemSynchronizedRootGroup have a one-to-many relationship with PBXFileSystemSynchronizedBuildFileExceptionSet /// through .exceptions. Exceptions are used to exclude files and override conffigurations. -public struct BuildableFolderExceptions: Sendable, Codable, Equatable, Hashable, ExpressibleByArrayLiteral { +public struct BuildableFolderExceptions: Sendable, Codable, Equatable, Hashable, ExpressibleByArrayLiteral, Sequence { /// A list with all the exceptions. public var exceptions: [BuildableFolderException] @@ -16,4 +16,9 @@ public struct BuildableFolderExceptions: Sendable, Codable, Equatable, Hashable, public init(exceptions: [BuildableFolderException]) { self.exceptions = exceptions } + + /// Returns an iterator over the contained exceptions. + public func makeIterator() -> [BuildableFolderException].Iterator { + exceptions.makeIterator() + } } From aa866546d8e358440eecdf1a0133c016ed8bd356 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 20 Sep 2025 13:27:59 +0200 Subject: [PATCH 5/8] Add resolvedPaths --- Sources/XcodeGraph/Models/BuildableFolder.swift | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Sources/XcodeGraph/Models/BuildableFolder.swift b/Sources/XcodeGraph/Models/BuildableFolder.swift index 34ce4be4..e2b7e9cc 100644 --- a/Sources/XcodeGraph/Models/BuildableFolder.swift +++ b/Sources/XcodeGraph/Models/BuildableFolder.swift @@ -8,13 +8,21 @@ public struct BuildableFolder: Sendable, Codable, Equatable, Hashable { /// The absolute path to the buildable folder. public var path: AbsolutePath - /// Exceptions to the buildable folder. + /// Exceptions associated with this buildable folder, describing files to exclude or per-file build configuration overrides. public var exceptions: BuildableFolderExceptions - /// Creates an instance of buildable folder. - /// - Parameter path: Absolute path to the buildable folder. - public init(path: AbsolutePath, exceptions: BuildableFolderExceptions) { + /// A list of absolute paths resolved from this folder, allowing consumers to work with all files without extra I/O + /// operations. + public var resolvedPaths: [AbsolutePath] + + /// Creates a new `BuildableFolder` instance. + /// - Parameters: + /// - path: The absolute path to the buildable folder. + /// - exceptions: The set of exceptions (such as excluded files or custom compiler flags) for the folder. + /// - resolvedPaths: The list of absolute file paths resolved from the folder, to avoid extra file system operations. + public init(path: AbsolutePath, exceptions: BuildableFolderExceptions, resolvedPaths: [AbsolutePath]) { self.path = path self.exceptions = exceptions + self.resolvedPaths = resolvedPaths } } From 94891e125a56b7720dbd7e1c3fc6a0704714a60d Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 20 Sep 2025 13:29:53 +0200 Subject: [PATCH 6/8] Add resolved files --- .../XcodeGraph/Models/BuildableFolder.swift | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Sources/XcodeGraph/Models/BuildableFolder.swift b/Sources/XcodeGraph/Models/BuildableFolder.swift index e2b7e9cc..3e72c3eb 100644 --- a/Sources/XcodeGraph/Models/BuildableFolder.swift +++ b/Sources/XcodeGraph/Models/BuildableFolder.swift @@ -1,9 +1,20 @@ import Path -/// A buildable folder maps to an PBXFileSystemSynchronizedRootGroup in Xcode projects. +/// Represents a file inside a buildable folder, along with any compiler flags to apply to it. +public struct BuildableFolderFile: Sendable, Codable, Equatable, Hashable { + /// The absolute path to the file within the buildable folder. + public let path: AbsolutePath + + /// Compiler flags to apply when building this file. An empty string means no extra flags. + public let compilerFlags: String +} + +/// A buildable folder maps to a PBXFileSystemSynchronizedRootGroup in Xcode projects. /// Synchronized groups were introduced in Xcode 16 to reduce git conflicts by having a reference /// to a folder whose content is "synchronized" by Xcode itself. Think of it as Xcode resolving /// the globs. +/// +/// This struct describes a buildable folder, the exception rules for files within it, and the resolved file list. public struct BuildableFolder: Sendable, Codable, Equatable, Hashable { /// The absolute path to the buildable folder. public var path: AbsolutePath @@ -11,18 +22,17 @@ public struct BuildableFolder: Sendable, Codable, Equatable, Hashable { /// Exceptions associated with this buildable folder, describing files to exclude or per-file build configuration overrides. public var exceptions: BuildableFolderExceptions - /// A list of absolute paths resolved from this folder, allowing consumers to work with all files without extra I/O - /// operations. - public var resolvedPaths: [AbsolutePath] + /// The files resolved from this buildable folder, each with any per-file compiler flags. + public var resolvedFiles: [BuildableFolderFile] /// Creates a new `BuildableFolder` instance. /// - Parameters: /// - path: The absolute path to the buildable folder. /// - exceptions: The set of exceptions (such as excluded files or custom compiler flags) for the folder. - /// - resolvedPaths: The list of absolute file paths resolved from the folder, to avoid extra file system operations. - public init(path: AbsolutePath, exceptions: BuildableFolderExceptions, resolvedPaths: [AbsolutePath]) { + /// - resolvedFiles: The list of files resolved from the folder, each file optionally having compiler flags. + public init(path: AbsolutePath, exceptions: BuildableFolderExceptions, resolvedFiles: [BuildableFolderFile]) { self.path = path self.exceptions = exceptions - self.resolvedPaths = resolvedPaths + self.resolvedFiles = resolvedFiles } } From ff99281e9b6dd72a76c241d3f0153f353979e5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Pi=C3=B1era?= Date: Wed, 24 Sep 2025 11:49:05 +0200 Subject: [PATCH 7/8] Add missing initializer --- Sources/XcodeGraph/Models/BuildableFolder.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sources/XcodeGraph/Models/BuildableFolder.swift b/Sources/XcodeGraph/Models/BuildableFolder.swift index 3e72c3eb..e2ea603d 100644 --- a/Sources/XcodeGraph/Models/BuildableFolder.swift +++ b/Sources/XcodeGraph/Models/BuildableFolder.swift @@ -7,6 +7,15 @@ public struct BuildableFolderFile: Sendable, Codable, Equatable, Hashable { /// Compiler flags to apply when building this file. An empty string means no extra flags. public let compilerFlags: String + + /// Initializes a buildable folder file. + /// - Parameters: + /// - path: The absolute path to the file within the buildable folder. + /// - compilerFlags: Compiler flags to apply when building this file. An empty string means no extra flags. + public init(path: AbsolutePath, compilerFlags: String) { + self.path = path + self.compilerFlags = compilerFlags + } } /// A buildable folder maps to a PBXFileSystemSynchronizedRootGroup in Xcode projects. From 5bf9838b293b8a6461a069c43e786a1979dbb077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Pi=C3=B1era?= Date: Wed, 24 Sep 2025 11:53:53 +0200 Subject: [PATCH 8/8] Make compiler flags optional --- Sources/XcodeGraph/Models/BuildableFolder.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/XcodeGraph/Models/BuildableFolder.swift b/Sources/XcodeGraph/Models/BuildableFolder.swift index e2ea603d..1a1ca412 100644 --- a/Sources/XcodeGraph/Models/BuildableFolder.swift +++ b/Sources/XcodeGraph/Models/BuildableFolder.swift @@ -6,13 +6,13 @@ public struct BuildableFolderFile: Sendable, Codable, Equatable, Hashable { public let path: AbsolutePath /// Compiler flags to apply when building this file. An empty string means no extra flags. - public let compilerFlags: String + public let compilerFlags: String? /// Initializes a buildable folder file. /// - Parameters: /// - path: The absolute path to the file within the buildable folder. /// - compilerFlags: Compiler flags to apply when building this file. An empty string means no extra flags. - public init(path: AbsolutePath, compilerFlags: String) { + public init(path: AbsolutePath, compilerFlags: String?) { self.path = path self.compilerFlags = compilerFlags }