From 9ccdb9e1abfe91f258678c04ba07470b9fd6e044 Mon Sep 17 00:00:00 2001 From: George Navarro Date: Fri, 18 Apr 2025 12:02:32 -0700 Subject: [PATCH 1/7] Added `customWorkingDirectory` and `useCustomWorkingDirectory` properties to `Scheme.Run` --- Sources/ProjectSpec/Scheme.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sources/ProjectSpec/Scheme.swift b/Sources/ProjectSpec/Scheme.swift index e417fcf0f..2af3f158f 100644 --- a/Sources/ProjectSpec/Scheme.swift +++ b/Sources/ProjectSpec/Scheme.swift @@ -132,6 +132,7 @@ public struct Scheme: Equatable { public static let disableThreadPerformanceCheckerDefault = false public static let debugEnabledDefault = true public static let enableGPUValidationModeDefault = true + public static let useCustomWorkingDirectoryDefault = false public var config: String? public var commandLineArguments: [String: Bool] @@ -153,6 +154,8 @@ public struct Scheme: Equatable { public var storeKitConfiguration: String? public var customLLDBInit: String? public var macroExpansion: String? + public var customWorkingDirectory: String? + public var useCustomWorkingDirectory: Bool public init( config: String? = nil, @@ -174,7 +177,9 @@ public struct Scheme: Equatable { simulateLocation: SimulateLocation? = nil, storeKitConfiguration: String? = nil, customLLDBInit: String? = nil, - macroExpansion: String? = nil + macroExpansion: String? = nil, + customWorkingDirectory: String? = nil, + useCustomWorkingDirectory: Bool = useCustomWorkingDirectoryDefault ) { self.config = config self.commandLineArguments = commandLineArguments @@ -195,6 +200,8 @@ public struct Scheme: Equatable { self.storeKitConfiguration = storeKitConfiguration self.customLLDBInit = customLLDBInit self.macroExpansion = macroExpansion + self.customWorkingDirectory = customWorkingDirectory + self.useCustomWorkingDirectory = useCustomWorkingDirectory } } @@ -523,6 +530,8 @@ extension Scheme.Run: JSONObjectConvertible { } customLLDBInit = jsonDictionary.json(atKeyPath: "customLLDBInit") macroExpansion = jsonDictionary.json(atKeyPath: "macroExpansion") + customWorkingDirectory = jsonDictionary.json(atKeyPath: "customWorkingDirectory") + useCustomWorkingDirectory = jsonDictionary.json(atKeyPath: "useCustomWorkingDirectory") ?? Scheme.Run.useCustomWorkingDirectoryDefault } } From 787213d433c4006520d0e36384f2ffbd7405616b Mon Sep 17 00:00:00 2001 From: George Navarro Date: Fri, 18 Apr 2025 12:03:16 -0700 Subject: [PATCH 2/7] Use new `customWorkingDirectory` and `useCustomWorkingDirectory` when generating `XCScheme.LaunchAction` --- Sources/XcodeGenKit/SchemeGenerator.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/XcodeGenKit/SchemeGenerator.swift b/Sources/XcodeGenKit/SchemeGenerator.swift index 69ad80faf..64f2661ee 100644 --- a/Sources/XcodeGenKit/SchemeGenerator.swift +++ b/Sources/XcodeGenKit/SchemeGenerator.swift @@ -355,6 +355,8 @@ public class SchemeGenerator { selectedDebuggerIdentifier: selectedDebuggerIdentifier(for: schemeTarget, run: scheme.run), selectedLauncherIdentifier: selectedLauncherIdentifier(for: schemeTarget, run: scheme.run), askForAppToLaunch: scheme.run?.askForAppToLaunch, + customWorkingDirectory: scheme.run?.customWorkingDirectory, + useCustomWorkingDirectory: scheme.run?.useCustomWorkingDirectory ?? Scheme.Run.useCustomWorkingDirectoryDefault, allowLocationSimulation: allowLocationSimulation, locationScenarioReference: locationScenarioReference, enableGPUFrameCaptureMode: scheme.run?.enableGPUFrameCaptureMode ?? XCScheme.LaunchAction.defaultGPUFrameCaptureMode, From 5f3e110cad628f37d3168539478d9d08a142ceab Mon Sep 17 00:00:00 2001 From: George Navarro Date: Fri, 18 Apr 2025 12:03:48 -0700 Subject: [PATCH 3/7] Updated ProjectSpec.md to document new `customWorkingDirectory` and `useCustomWorkingDirectory` properties --- Docs/ProjectSpec.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 83166e9c4..52de6a493 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -1054,6 +1054,8 @@ A multiline script can be written using the various YAML multiline methods, for ### Run Action - [ ] **executable**: **String** - the name of the target to launch as an executable. Defaults to the first runnable build target in the scheme, or the first build target if a runnable build target is not found - [ ] **customLLDBInit**: **String** - the absolute path to the custom `.lldbinit` file +- [ ] **customWorkingDirectory**: **String** - a path to use as the working directory when launching the executable. +- [ ] **useCustomWorkingDirectory**: **Bool** - sets if the custom working directory should be used. This defaults to false. ### Test Action From c208402c89b7377e4e9ad3cf67365c41f5f4e6f4 Mon Sep 17 00:00:00 2001 From: George Navarro Date: Thu, 17 Jul 2025 11:48:53 -0700 Subject: [PATCH 4/7] Fix for not setting customWorkingDirectory in the toJSONValue function --- Sources/ProjectSpec/Scheme.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/ProjectSpec/Scheme.swift b/Sources/ProjectSpec/Scheme.swift index 2af3f158f..228b8ef0b 100644 --- a/Sources/ProjectSpec/Scheme.swift +++ b/Sources/ProjectSpec/Scheme.swift @@ -584,6 +584,9 @@ extension Scheme.Run: JSONEncodable { if let customLLDBInit = customLLDBInit { dict["customLLDBInit"] = customLLDBInit } + if let customWorkingDirectory = customWorkingDirectory { + dict["customWorkingDirectory"] = customWorkingDirectory + } return dict } } From 14b0ef97294b80ec5b01e71241d1d4da5e8c3dbc Mon Sep 17 00:00:00 2001 From: George Navarro Date: Thu, 17 Jul 2025 11:42:03 -0700 Subject: [PATCH 5/7] Added test to make sure usCustomWorkingDirectory value is true when the customWorkingDirectory is set to non nil --- Tests/XcodeGenKitTests/SchemeGeneratorTests.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift b/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift index edad2183b..d876b3f8b 100644 --- a/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift @@ -53,7 +53,7 @@ class SchemeGeneratorTests: XCTestCase { let scheme = try Scheme( name: "MyScheme", build: Scheme.Build(targets: [buildTarget], preActions: [preAction]), - run: Scheme.Run(config: "Debug", enableGPUFrameCaptureMode: .metal, askForAppToLaunch: true, launchAutomaticallySubstyle: "2", simulateLocation: simulateLocation, storeKitConfiguration: storeKitConfiguration, customLLDBInit: "/sample/.lldbinit"), + run: Scheme.Run(config: "Debug", enableGPUFrameCaptureMode: .metal, askForAppToLaunch: true, launchAutomaticallySubstyle: "2", simulateLocation: simulateLocation, storeKitConfiguration: storeKitConfiguration, customLLDBInit: "/sample/.lldbinit", customWorkingDirectory: "/test"), test: Scheme.Test(config: "Debug", targets: [ Scheme.Test.TestTarget(targetReference: TestableTargetReference(framework.name), location: "test.gpx"), Scheme.Test.TestTarget(targetReference: TestableTargetReference(framework.name), location: "New York, NY, USA") @@ -114,7 +114,10 @@ class SchemeGeneratorTests: XCTestCase { try expect(xcscheme.launchAction?.enableGPUFrameCaptureMode) == .metal try expect(xcscheme.testAction?.customLLDBInitFile) == "/test/.lldbinit" try expect(xcscheme.testAction?.systemAttachmentLifetime).to.beNil() - + + try expect(xcscheme.launchAction?.useCustomWorkingDirectory) == true + try expect(xcscheme.launchAction?.customWorkingDirectory) == "/test" + try expect(xcscheme.testAction?.testables[0].locationScenarioReference?.referenceType) == "0" try expect(xcscheme.testAction?.testables[0].locationScenarioReference?.identifier) == "../test.gpx" From 9c2ec1abfa0b00588c2cde648dbcd86ba1c53b2f Mon Sep 17 00:00:00 2001 From: George Navarro Date: Thu, 17 Jul 2025 11:22:21 -0700 Subject: [PATCH 6/7] Change to infer the value of SchemaGenerator.LaunchAction.useCustomWorkingDirectory based on the value of Schema.Run.customWorkingDirectory --- Sources/ProjectSpec/Scheme.swift | 7 +------ Sources/XcodeGenKit/SchemeGenerator.swift | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Sources/ProjectSpec/Scheme.swift b/Sources/ProjectSpec/Scheme.swift index 228b8ef0b..de8cc5126 100644 --- a/Sources/ProjectSpec/Scheme.swift +++ b/Sources/ProjectSpec/Scheme.swift @@ -132,7 +132,6 @@ public struct Scheme: Equatable { public static let disableThreadPerformanceCheckerDefault = false public static let debugEnabledDefault = true public static let enableGPUValidationModeDefault = true - public static let useCustomWorkingDirectoryDefault = false public var config: String? public var commandLineArguments: [String: Bool] @@ -155,7 +154,6 @@ public struct Scheme: Equatable { public var customLLDBInit: String? public var macroExpansion: String? public var customWorkingDirectory: String? - public var useCustomWorkingDirectory: Bool public init( config: String? = nil, @@ -178,8 +176,7 @@ public struct Scheme: Equatable { storeKitConfiguration: String? = nil, customLLDBInit: String? = nil, macroExpansion: String? = nil, - customWorkingDirectory: String? = nil, - useCustomWorkingDirectory: Bool = useCustomWorkingDirectoryDefault + customWorkingDirectory: String? = nil ) { self.config = config self.commandLineArguments = commandLineArguments @@ -201,7 +198,6 @@ public struct Scheme: Equatable { self.customLLDBInit = customLLDBInit self.macroExpansion = macroExpansion self.customWorkingDirectory = customWorkingDirectory - self.useCustomWorkingDirectory = useCustomWorkingDirectory } } @@ -531,7 +527,6 @@ extension Scheme.Run: JSONObjectConvertible { customLLDBInit = jsonDictionary.json(atKeyPath: "customLLDBInit") macroExpansion = jsonDictionary.json(atKeyPath: "macroExpansion") customWorkingDirectory = jsonDictionary.json(atKeyPath: "customWorkingDirectory") - useCustomWorkingDirectory = jsonDictionary.json(atKeyPath: "useCustomWorkingDirectory") ?? Scheme.Run.useCustomWorkingDirectoryDefault } } diff --git a/Sources/XcodeGenKit/SchemeGenerator.swift b/Sources/XcodeGenKit/SchemeGenerator.swift index 64f2661ee..5779b72c9 100644 --- a/Sources/XcodeGenKit/SchemeGenerator.swift +++ b/Sources/XcodeGenKit/SchemeGenerator.swift @@ -356,7 +356,7 @@ public class SchemeGenerator { selectedLauncherIdentifier: selectedLauncherIdentifier(for: schemeTarget, run: scheme.run), askForAppToLaunch: scheme.run?.askForAppToLaunch, customWorkingDirectory: scheme.run?.customWorkingDirectory, - useCustomWorkingDirectory: scheme.run?.useCustomWorkingDirectory ?? Scheme.Run.useCustomWorkingDirectoryDefault, + useCustomWorkingDirectory: scheme.run?.customWorkingDirectory != nil, allowLocationSimulation: allowLocationSimulation, locationScenarioReference: locationScenarioReference, enableGPUFrameCaptureMode: scheme.run?.enableGPUFrameCaptureMode ?? XCScheme.LaunchAction.defaultGPUFrameCaptureMode, From 5ebe4ebf91bbc81d881505b8333791879fea3043 Mon Sep 17 00:00:00 2001 From: George Navarro Date: Sun, 20 Jul 2025 20:57:09 -0700 Subject: [PATCH 7/7] Removed useCustomWorkingDirectory from the project spec now that it is no longer user defined. --- Docs/ProjectSpec.md | 1 - 1 file changed, 1 deletion(-) diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 52de6a493..071154125 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -1055,7 +1055,6 @@ A multiline script can be written using the various YAML multiline methods, for - [ ] **executable**: **String** - the name of the target to launch as an executable. Defaults to the first runnable build target in the scheme, or the first build target if a runnable build target is not found - [ ] **customLLDBInit**: **String** - the absolute path to the custom `.lldbinit` file - [ ] **customWorkingDirectory**: **String** - a path to use as the working directory when launching the executable. -- [ ] **useCustomWorkingDirectory**: **Bool** - sets if the custom working directory should be used. This defaults to false. ### Test Action