diff --git a/CHANGELOG.md b/CHANGELOG.md index e0cb51a2..0ca8ae31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ #### Added - Add `Scheme.Test.TestTarget.skipped` to allow skipping of an entire test target. [#916](https://github.com/yonaskolb/XcodeGen/pull/916) @codeman9 +- Added ability to set custom LLDBInit scripts for launch and test schemes [#929](https://github.com/yonaskolb/XcodeGen/pull/929) @polac24 #### Fixed - Allow SDK dependencies to be embedded. [#922](https://github.com/yonaskolb/XcodeGen/pull/922) @k-thorat diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index b5c78adf..322a4e2d 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -782,12 +782,14 @@ 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 build target in the scheme +- [ ] **customLLDBInit**: **String** - the absolute path to the custom `.lldbinit` file ### Test Action - [ ] **gatherCoverageData**: **Bool** - a boolean that indicates if this scheme should gather coverage data. This defaults to false - [ ] **coverageTargets**: **[String]** - a list of targets to gather code coverage. Each entry can either be a simple string, or a string using [Project Reference](#project-reference) - [ ] **targets**: **[[Test Target](#test-target)]** - a list of targets to test. Each entry can either be a simple string, or a [Test Target](#test-target) +- [ ] **customLLDBInit**: **String** - the absolute path to the custom `.lldbinit` file #### Test Target - [x] **name**: **String** - The name of the target diff --git a/Sources/ProjectSpec/Scheme.swift b/Sources/ProjectSpec/Scheme.swift index 1921fd3f..d872129d 100644 --- a/Sources/ProjectSpec/Scheme.swift +++ b/Sources/ProjectSpec/Scheme.swift @@ -113,6 +113,7 @@ public struct Scheme: Equatable { public var debugEnabled: Bool public var simulateLocation: SimulateLocation? public var executable: String? + public var customLLDBInit: String? public init( config: String, @@ -128,7 +129,8 @@ public struct Scheme: Equatable { askForAppToLaunch: Bool? = nil, launchAutomaticallySubstyle: String? = nil, debugEnabled: Bool = debugEnabledDefault, - simulateLocation: SimulateLocation? = nil + simulateLocation: SimulateLocation? = nil, + customLLDBInit: String? = nil ) { self.config = config self.commandLineArguments = commandLineArguments @@ -143,6 +145,7 @@ public struct Scheme: Equatable { self.launchAutomaticallySubstyle = launchAutomaticallySubstyle self.debugEnabled = debugEnabled self.simulateLocation = simulateLocation + self.customLLDBInit = customLLDBInit } } @@ -163,6 +166,7 @@ public struct Scheme: Equatable { public var language: String? public var region: String? public var debugEnabled: Bool + public var customLLDBInit: String? public struct TestTarget: Equatable, ExpressibleByStringLiteral { public static let randomExecutionOrderDefault = false @@ -216,7 +220,8 @@ public struct Scheme: Equatable { environmentVariables: [XCScheme.EnvironmentVariable] = [], language: String? = nil, region: String? = nil, - debugEnabled: Bool = debugEnabledDefault + debugEnabled: Bool = debugEnabledDefault, + customLLDBInit: String? = nil ) { self.config = config self.gatherCoverageData = gatherCoverageData @@ -230,6 +235,7 @@ public struct Scheme: Equatable { self.language = language self.region = region self.debugEnabled = debugEnabled + self.customLLDBInit = customLLDBInit } public var shouldUseLaunchSchemeArgsEnv: Bool { @@ -375,6 +381,7 @@ extension Scheme.Run: JSONObjectConvertible { if let askLaunch: Bool = jsonDictionary.json(atKeyPath: "askForAppToLaunch") { askForAppToLaunch = askLaunch } + customLLDBInit = jsonDictionary.json(atKeyPath: "customLLDBInit") } } @@ -408,6 +415,9 @@ extension Scheme.Run: JSONEncodable { if let simulateLocation = simulateLocation { dict["simulateLocation"] = simulateLocation.toJSONValue() } + if let customLLDBInit = customLLDBInit { + dict["customLLDBInit"] = customLLDBInit + } return dict } } @@ -439,6 +449,7 @@ extension Scheme.Test: JSONObjectConvertible { language = jsonDictionary.json(atKeyPath: "language") region = jsonDictionary.json(atKeyPath: "region") debugEnabled = jsonDictionary.json(atKeyPath: "debugEnabled") ?? Scheme.Test.debugEnabledDefault + customLLDBInit = jsonDictionary.json(atKeyPath: "customLLDBInit") } } @@ -468,6 +479,10 @@ extension Scheme.Test: JSONEncodable { dict["debugEnabled"] = debugEnabled } + if let customLLDBInit = customLLDBInit { + dict["customLLDBInit"] = customLLDBInit + } + return dict } } diff --git a/Sources/XcodeGenKit/SchemeGenerator.swift b/Sources/XcodeGenKit/SchemeGenerator.swift index f44bf4e9..11104324 100644 --- a/Sources/XcodeGenKit/SchemeGenerator.swift +++ b/Sources/XcodeGenKit/SchemeGenerator.swift @@ -219,7 +219,8 @@ public class SchemeGenerator { commandlineArguments: testCommandLineArgs, environmentVariables: testVariables, language: scheme.test?.language, - region: scheme.test?.region + region: scheme.test?.region, + customLLDBInitFile: scheme.test?.customLLDBInit ) let allowLocationSimulation = scheme.run?.simulateLocation?.allow ?? true @@ -250,7 +251,8 @@ public class SchemeGenerator { environmentVariables: launchVariables, language: scheme.run?.language, region: scheme.run?.region, - launchAutomaticallySubstyle: scheme.run?.launchAutomaticallySubstyle + launchAutomaticallySubstyle: scheme.run?.launchAutomaticallySubstyle, + customLLDBInitFile: scheme.run?.customLLDBInit ) let profileAction = XCScheme.ProfileAction( diff --git a/Tests/Fixtures/TestProject/.lldbinit b/Tests/Fixtures/TestProject/.lldbinit new file mode 100644 index 00000000..e69de29b diff --git a/Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/App_Scheme.xcscheme b/Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/App_Scheme.xcscheme index 55f0c6c9..16b808cb 100644 --- a/Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/App_Scheme.xcscheme +++ b/Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/App_Scheme.xcscheme @@ -28,7 +28,8 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" codeCoverageEnabled = "YES" onlyGenerateCoverageForSpecifiedTargets = "NO" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES" + customLLDBInitFile = "${SRCROOT}/.lldbinit"> @@ -74,7 +75,8 @@ ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" debugServiceExtension = "internal" - allowLocationSimulation = "YES"> + allowLocationSimulation = "YES" + customLLDBInitFile = "${SRCROOT}/.lldbinit">