Skip to content
1 change: 1 addition & 0 deletions Docs/ProjectSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,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

Expand Down
9 changes: 8 additions & 1 deletion Sources/ProjectSpec/Scheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,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,
Expand All @@ -174,7 +175,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
Expand All @@ -195,6 +197,7 @@ public struct Scheme: Equatable {
self.storeKitConfiguration = storeKitConfiguration
self.customLLDBInit = customLLDBInit
self.macroExpansion = macroExpansion
self.customWorkingDirectory = customWorkingDirectory
}
}

Expand Down Expand Up @@ -523,6 +526,7 @@ extension Scheme.Run: JSONObjectConvertible {
}
customLLDBInit = jsonDictionary.json(atKeyPath: "customLLDBInit")
macroExpansion = jsonDictionary.json(atKeyPath: "macroExpansion")
customWorkingDirectory = jsonDictionary.json(atKeyPath: "customWorkingDirectory")
}
}

Expand Down Expand Up @@ -575,6 +579,9 @@ extension Scheme.Run: JSONEncodable {
if let customLLDBInit = customLLDBInit {
dict["customLLDBInit"] = customLLDBInit
}
if let customWorkingDirectory = customWorkingDirectory {
dict["customWorkingDirectory"] = customWorkingDirectory
}
return dict
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/XcodeGenKit/SchemeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?.customWorkingDirectory != nil,
allowLocationSimulation: allowLocationSimulation,
locationScenarioReference: locationScenarioReference,
enableGPUFrameCaptureMode: scheme.run?.enableGPUFrameCaptureMode ?? XCScheme.LaunchAction.defaultGPUFrameCaptureMode,
Expand Down
7 changes: 5 additions & 2 deletions Tests/XcodeGenKitTests/SchemeGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"

Expand Down