Feature: Custom Working Directory (#1543)

* Added `customWorkingDirectory` and `useCustomWorkingDirectory` properties to `Scheme.Run`

* Use new `customWorkingDirectory` and `useCustomWorkingDirectory` when generating `XCScheme.LaunchAction`

* Updated ProjectSpec.md to document new `customWorkingDirectory` and `useCustomWorkingDirectory` properties

* Fix for not setting customWorkingDirectory in the toJSONValue function

* Added test to make sure usCustomWorkingDirectory value is true when the customWorkingDirectory is set to non nil

* Change to infer the value of SchemaGenerator.LaunchAction.useCustomWorkingDirectory based on the value of Schema.Run.customWorkingDirectory

* Removed useCustomWorkingDirectory from the project spec now that it is no longer user defined.
This commit is contained in:
George Navarro
2025-07-22 02:16:05 -07:00
committed by GitHub
parent a1c7544271
commit 3251691527
4 changed files with 16 additions and 3 deletions
+1
View File
@@ -1059,6 +1059,7 @@ 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.
### Test Action
+8 -1
View File
@@ -161,6 +161,7 @@ public struct Scheme: Equatable {
public var storeKitConfiguration: String?
public var customLLDBInit: String?
public var macroExpansion: String?
public var customWorkingDirectory: String?
public init(
config: String? = nil,
@@ -186,7 +187,8 @@ public struct Scheme: Equatable {
simulateLocation: SimulateLocation? = nil,
storeKitConfiguration: String? = nil,
customLLDBInit: String? = nil,
macroExpansion: String? = nil
macroExpansion: String? = nil,
customWorkingDirectory: String? = nil
) {
self.config = config
self.commandLineArguments = commandLineArguments
@@ -211,6 +213,7 @@ public struct Scheme: Equatable {
self.storeKitConfiguration = storeKitConfiguration
self.customLLDBInit = customLLDBInit
self.macroExpansion = macroExpansion
self.customWorkingDirectory = customWorkingDirectory
}
}
@@ -559,6 +562,7 @@ extension Scheme.Run: JSONObjectConvertible {
}
customLLDBInit = jsonDictionary.json(atKeyPath: "customLLDBInit")
macroExpansion = jsonDictionary.json(atKeyPath: "macroExpansion")
customWorkingDirectory = jsonDictionary.json(atKeyPath: "customWorkingDirectory")
}
}
@@ -627,6 +631,9 @@ extension Scheme.Run: JSONEncodable {
if let customLLDBInit = customLLDBInit {
dict["customLLDBInit"] = customLLDBInit
}
if let customWorkingDirectory = customWorkingDirectory {
dict["customWorkingDirectory"] = customWorkingDirectory
}
return dict
}
}
@@ -359,6 +359,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?.customWorkingDirectory != nil,
allowLocationSimulation: allowLocationSimulation,
locationScenarioReference: locationScenarioReference,
enableGPUFrameCaptureMode: scheme.run?.enableGPUFrameCaptureMode ?? XCScheme.LaunchAction.defaultGPUFrameCaptureMode,
@@ -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"