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.

16 changes: 13 additions & 3 deletions Sources/XcodeGraph/Models/RunAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public struct RunAction: Equatable, Codable, Sendable {
public let expandVariableFromTarget: TargetReference?
public let launchStyle: LaunchStyle
public let appClipInvocationURL: URL?
public var customWorkingDirectory: AbsolutePath?
public var useCustomWorkingDirectory: Bool
Comment on lines +21 to +22
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Default useCustomWorkingDirectory to avoid breaking Decodable; consider restricting external mutation

Adding a non-optional Bool without a default breaks backward Decoding when the key is absent. Also consider limiting write access to maintain invariants.

Apply this diff to make Decoding backward-compatible and reduce external mutation risks:

-    public var customWorkingDirectory: AbsolutePath?
-    public var useCustomWorkingDirectory: Bool
+    public internal(set) var customWorkingDirectory: AbsolutePath?
+    public internal(set) var useCustomWorkingDirectory: Bool = false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public var customWorkingDirectory: AbsolutePath?
public var useCustomWorkingDirectory: Bool
public internal(set) var customWorkingDirectory: AbsolutePath?
public internal(set) var useCustomWorkingDirectory: Bool = false
🤖 Prompt for AI Agents
In Sources/XcodeGraph/Models/RunAction.swift around lines 21–22, make
useCustomWorkingDirectory backward-compatible and less writable by giving it a
default value and restricting external mutation: change its declaration to
provide a default (e.g., = false) so Decodable won’t break when the key is
missing, and limit external write access (e.g., public private(set) var) so
callers cannot mutate it freely; also adjust any explicit initializers or
CodingKeys/Decodable init to respect the default if present.


// MARK: - Init

Expand All @@ -35,7 +37,9 @@ public struct RunAction: Equatable, Codable, Sendable {
metalOptions: MetalOptions? = nil,
expandVariableFromTarget: TargetReference? = nil,
launchStyle: LaunchStyle = .automatically,
appClipInvocationURL: URL? = nil
appClipInvocationURL: URL? = nil,
customWorkingDirectory: AbsolutePath? = nil,
useCustomWorkingDirectory: Bool = false
Comment on lines +40 to +42
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Guard against invalid state when enabling custom working directory without a path

Ensure we don’t end up with useCustomWorkingDirectory == true and customWorkingDirectory == nil.

Add a precondition at the beginning of the initializer body:

precondition(
    !useCustomWorkingDirectory || customWorkingDirectory != nil,
    "useCustomWorkingDirectory requires customWorkingDirectory to be non-nil"
)
🤖 Prompt for AI Agents
In Sources/XcodeGraph/Models/RunAction.swift around lines 40 to 42, guard
against the invalid state where useCustomWorkingDirectory is true while
customWorkingDirectory is nil by adding a precondition at the start of the
initializer body: check that !useCustomWorkingDirectory ||
customWorkingDirectory != nil and provide a clear message like
"useCustomWorkingDirectory requires customWorkingDirectory to be non-nil".

) {
self.configurationName = configurationName
self.attachDebugger = attachDebugger
Expand All @@ -51,6 +55,8 @@ public struct RunAction: Equatable, Codable, Sendable {
self.expandVariableFromTarget = expandVariableFromTarget
self.launchStyle = launchStyle
self.appClipInvocationURL = appClipInvocationURL
self.customWorkingDirectory = customWorkingDirectory
self.useCustomWorkingDirectory = useCustomWorkingDirectory
}
}

Expand All @@ -76,7 +82,9 @@ public struct RunAction: Equatable, Codable, Sendable {
),
expandVariableFromTarget: TargetReference? = nil,
launchStyle: LaunchStyle = .automatically,
appClipInvocationURL: URL? = nil
appClipInvocationURL: URL? = nil,
customWorkingDirectory: AbsolutePath? = nil,
useCustomWorkingDirectory: Bool = false
) -> RunAction {
RunAction(
configurationName: configurationName,
Expand All @@ -92,7 +100,9 @@ public struct RunAction: Equatable, Codable, Sendable {
metalOptions: metalOptions,
expandVariableFromTarget: expandVariableFromTarget,
launchStyle: launchStyle,
appClipInvocationURL: appClipInvocationURL
appClipInvocationURL: appClipInvocationURL,
customWorkingDirectory: customWorkingDirectory,
useCustomWorkingDirectory: useCustomWorkingDirectory
)
}
}
Expand Down
7 changes: 6 additions & 1 deletion Sources/XcodeGraph/Models/Target.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ public struct Target: Equatable, Hashable, Comparable, Codable, Sendable {
public var playgrounds: [AbsolutePath]
public let additionalFiles: [FileElement]
public var buildRules: [BuildRule]
@available(*, deprecated, message: """
The prune attribute coupled XcodeGraph to a particular use-case of Tuist and therefore
we removed it in favor of using metadata as an in-memory context holder that can be leveraged
using conventional tags.
""")
public var prune: Bool
public let mergedBinaryType: MergedBinaryType
public let mergeable: Bool
public let onDemandResourcesTags: OnDemandResourcesTags?
public let metadata: TargetMetadata
public var metadata: TargetMetadata
public let type: TargetType
public let packages: [AbsolutePath]
public let buildableFolders: [BuildableFolder]
Expand Down