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.

39 changes: 35 additions & 4 deletions Sources/XcodeGraph/Models/BuildableFolder.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
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?

/// 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.
/// 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

/// Creates an instance of buildable folder.
/// - Parameter path: Absolute path to the buildable folder.
public init(path: AbsolutePath) {
/// Exceptions associated with this buildable folder, describing files to exclude or per-file build configuration overrides.
public var exceptions: BuildableFolderExceptions

/// 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.
/// - resolvedFiles: The list of files resolved from the folder, each file optionally having compiler flags.
public init(path: AbsolutePath, exceptions: BuildableFolderExceptions, resolvedFiles: [BuildableFolderFile]) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it's possible to have a default init (as right now) and a convenience one with the new params? or make them optional with fallback values in the init? This would not beak all projects

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not an interface you directly interact with in your Project.swift manifests if that's what you're worried about

self.path = path
self.exceptions = exceptions
self.resolvedFiles = resolvedFiles
}
}
19 changes: 19 additions & 0 deletions Sources/XcodeGraph/Models/BuildableFolderException.swift
Original file line number Diff line number Diff line change
@@ -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 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:
/// - 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(excluded: [AbsolutePath], compilerFlags: [AbsolutePath: String]) {
self.excluded = excluded
self.compilerFlags = compilerFlags
}
}
24 changes: 24 additions & 0 deletions Sources/XcodeGraph/Models/BuildableFolderExceptions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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, Sequence {
/// 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
}

public init(exceptions: [BuildableFolderException]) {
self.exceptions = exceptions
}

/// Returns an iterator over the contained exceptions.
public func makeIterator() -> [BuildableFolderException].Iterator {
exceptions.makeIterator()
}
}