Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom lldinit for a scheme #929

Merged
merged 5 commits into from
Aug 12, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Docs/ProjectSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 17 additions & 2 deletions Sources/ProjectSpec/Scheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -143,6 +145,7 @@ public struct Scheme: Equatable {
self.launchAutomaticallySubstyle = launchAutomaticallySubstyle
self.debugEnabled = debugEnabled
self.simulateLocation = simulateLocation
self.customLLDBInit = customLLDBInit
}
}

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -230,6 +235,7 @@ public struct Scheme: Equatable {
self.language = language
self.region = region
self.debugEnabled = debugEnabled
self.customLLDBInit = customLLDBInit
}

public var shouldUseLaunchSchemeArgsEnv: Bool {
Expand Down Expand Up @@ -375,6 +381,7 @@ extension Scheme.Run: JSONObjectConvertible {
if let askLaunch: Bool = jsonDictionary.json(atKeyPath: "askForAppToLaunch") {
askForAppToLaunch = askLaunch
}
customLLDBInit = jsonDictionary.json(atKeyPath: "customLLDBInit")
}
}

Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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")
}
}

Expand Down Expand Up @@ -468,6 +479,10 @@ extension Scheme.Test: JSONEncodable {
dict["debugEnabled"] = debugEnabled
}

if let customLLDBInit = customLLDBInit {
dict["customLLDBInit"] = customLLDBInit
}

return dict
}
}
Expand Down
6 changes: 4 additions & 2 deletions Sources/XcodeGenKit/SchemeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "NO"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
customLLDBInitFile = "${SRCROOT}/.lldbinit">
<Testables>
<TestableReference
skipped = "NO">
Expand Down Expand Up @@ -74,7 +75,8 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
allowLocationSimulation = "YES"
customLLDBInitFile = "${SRCROOT}/.lldbinit">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
Expand Down
2 changes: 2 additions & 0 deletions Tests/Fixtures/TestProject/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,15 @@ schemes:
simulateLocation:
allow: true
defaultLocation: Honolulu, HI, USA
customLLDBInit: ${SRCROOT}/.lldbinit
test:
gatherCoverageData: true
targets:
- App_iOS_UITests
- name: App_iOS_Tests
parallelizable: true
randomExecutionOrder: true
customLLDBInit: ${SRCROOT}/.lldbinit
targetTemplates:
MyTemplate:
scheme: {}
Expand Down
5 changes: 4 additions & 1 deletion Tests/XcodeGenKitTests/SchemeGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class SchemeGeneratorTests: XCTestCase {
let scheme = Scheme(
name: "MyScheme",
build: Scheme.Build(targets: [buildTarget], preActions: [preAction]),
run: Scheme.Run(config: "Debug", askForAppToLaunch: true, launchAutomaticallySubstyle: "2", simulateLocation: simulateLocation)
run: Scheme.Run(config: "Debug", askForAppToLaunch: true, launchAutomaticallySubstyle: "2", simulateLocation: simulateLocation, customLLDBInit: "/sample/.lldbinit"),
test: Scheme.Test(config: "Debug", customLLDBInit: "/test/.lldbinit")
)
let project = Project(
name: "test",
Expand Down Expand Up @@ -99,6 +100,8 @@ class SchemeGeneratorTests: XCTestCase {
try expect(xcscheme.launchAction?.allowLocationSimulation) == true
try expect(xcscheme.launchAction?.locationScenarioReference?.referenceType) == Scheme.SimulateLocation.ReferenceType.predefined.rawValue
try expect(xcscheme.launchAction?.locationScenarioReference?.identifier) == "New York, NY, USA"
try expect(xcscheme.launchAction?.customLLDBInitFile) == "/sample/.lldbinit"
try expect(xcscheme.testAction?.customLLDBInitFile) == "/test/.lldbinit"
}

$0.it("generates scheme with multiple configs") {
Expand Down