Skip to content

Commit

Permalink
Add customLLDBInitFile (#553)
Browse files Browse the repository at this point in the history
* Add customLLDBInitFile

* Minor changelog change
  • Loading branch information
polac24 committed Jun 24, 2020
1 parent e7905a6 commit 5900fae
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Next

### Added

- Added `LaunchAction.customLLDBInitFile` and `TestAction.customLLDBInitFile` attributes https://github.com/tuist/xcodeproj/pull/553 by @polac24

## 7.11.1

### Added
Expand Down
13 changes: 11 additions & 2 deletions Sources/XcodeProj/Scheme/XCScheme+LaunchAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ extension XCScheme {
public var launchAutomaticallySubstyle: String?
// To enable the option in Xcode: defaults write com.apple.dt.Xcode IDEDebuggerFeatureSetting 12
public var customLaunchCommand: String?
public var customLLDBInitFile: String?

// MARK: - Init

Expand Down Expand Up @@ -101,7 +102,8 @@ extension XCScheme {
language: String? = nil,
region: String? = nil,
launchAutomaticallySubstyle: String? = nil,
customLaunchCommand: String? = nil) {
customLaunchCommand: String? = nil,
customLLDBInitFile: String? = nil) {
self.runnable = runnable
self.macroExpansion = macroExpansion
self.buildConfiguration = buildConfiguration
Expand Down Expand Up @@ -133,6 +135,7 @@ extension XCScheme {
self.region = region
self.launchAutomaticallySubstyle = launchAutomaticallySubstyle
self.customLaunchCommand = customLaunchCommand
self.customLLDBInitFile = customLLDBInitFile
super.init(preActions, postActions)
}

Expand Down Expand Up @@ -205,6 +208,7 @@ extension XCScheme {
region = element.attributes["region"]
launchAutomaticallySubstyle = element.attributes["launchAutomaticallySubstyle"]
customLaunchCommand = element.attributes["customLaunchCommand"]
customLLDBInitFile = element.attributes["customLLDBInitFile"]

try super.init(element: element)
}
Expand Down Expand Up @@ -306,6 +310,10 @@ extension XCScheme {
element.attributes["customLaunchCommand"] = customLaunchCommand
}

if let customLLDBInitFile = customLLDBInitFile {
element.attributes["customLLDBInitFile"] = customLLDBInitFile
}

if !additionalOptions.isEmpty {
let additionalOptionsElement = element.addChild(AEXMLElement(name: "AdditionalOptions"))
additionalOptions.forEach { additionalOption in
Expand Down Expand Up @@ -351,7 +359,8 @@ extension XCScheme {
language == rhs.language &&
region == rhs.region &&
launchAutomaticallySubstyle == rhs.launchAutomaticallySubstyle &&
customLaunchCommand == rhs.customLaunchCommand
customLaunchCommand == rhs.customLaunchCommand &&
customLLDBInitFile == rhs.customLLDBInitFile
}
}
}
12 changes: 10 additions & 2 deletions Sources/XcodeProj/Scheme/XCScheme+TestAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extension XCScheme {
public var region: String?
public var systemAttachmentLifetime: AttachmentLifetime?
public var userAttachmentLifetime: AttachmentLifetime?
public var customLLDBInitFile: String?

// MARK: - Init

Expand All @@ -62,7 +63,8 @@ extension XCScheme {
language: String? = nil,
region: String? = nil,
systemAttachmentLifetime: AttachmentLifetime? = nil,
userAttachmentLifetime: AttachmentLifetime? = nil) {
userAttachmentLifetime: AttachmentLifetime? = nil,
customLLDBInitFile: String? = nil) {
self.buildConfiguration = buildConfiguration
self.macroExpansion = macroExpansion
self.testables = testables
Expand All @@ -85,6 +87,7 @@ extension XCScheme {
self.region = region
self.systemAttachmentLifetime = systemAttachmentLifetime
self.userAttachmentLifetime = userAttachmentLifetime
self.customLLDBInitFile = customLLDBInitFile
super.init(preActions, postActions)
}

Expand Down Expand Up @@ -136,6 +139,7 @@ extension XCScheme {
.flatMap(AttachmentLifetime.init(rawValue:))
userAttachmentLifetime = element.attributes["userAttachmentLifetime"]
.flatMap(AttachmentLifetime.init(rawValue:))
customLLDBInitFile = element.attributes["customLLDBInitFile"]
try super.init(element: element)
}

Expand Down Expand Up @@ -176,6 +180,9 @@ extension XCScheme {
if case .keepAlways? = userAttachmentLifetime {
attributes["userAttachmentLifetime"] = userAttachmentLifetime?.rawValue
}
if let customLLDBInitFile = customLLDBInitFile {
attributes["customLLDBInitFile"] = customLLDBInitFile
}

let element = AEXMLElement(name: "TestAction", value: nil, attributes: attributes)
super.writeXML(parent: element)
Expand Down Expand Up @@ -246,7 +253,8 @@ extension XCScheme {
region == rhs.region &&
systemAttachmentLifetime == rhs.systemAttachmentLifetime &&
userAttachmentLifetime == rhs.userAttachmentLifetime &&
codeCoverageTargets == rhs.codeCoverageTargets
codeCoverageTargets == rhs.codeCoverageTargets &&
customLLDBInitFile == rhs.customLLDBInitFile
}
}
}
29 changes: 29 additions & 0 deletions Tests/XcodeProjTests/Scheme/XCSchemeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,34 @@ final class XCSchemeIntegrationTests: XCTestCase {
XCTAssertEqual(subject, reconstructedSubject)
}

func test_launchAction_customLLDBInitFile_serializingAndDeserializing() throws {
// Given
let lldbInitPath = "/Users/user/custom/.lldbinit"
let subject = XCScheme.LaunchAction(runnable: nil, buildConfiguration: "Debug", customLLDBInitFile: lldbInitPath)


// When
let element = subject.xmlElement()
let reconstructedSubject = try XCScheme.LaunchAction(element: element)

// Then
XCTAssertEqual(subject, reconstructedSubject)
}

func test_testAction_customLLDBInitFile_serializingAndDeserializing() throws {
// Given
let lldbInitPath = "/Users/user/custom/.lldbinit"
let subject = XCScheme.TestAction(buildConfiguration: "Debug", macroExpansion: nil, customLLDBInitFile: lldbInitPath)


// When
let element = subject.xmlElement()
let reconstructedSubject = try XCScheme.TestAction(element: element)

// Then
XCTAssertEqual(subject, reconstructedSubject)
}

// MARK: - Private

private func assert(scheme: XCScheme) {
Expand Down Expand Up @@ -277,6 +305,7 @@ final class XCSchemeIntegrationTests: XCTestCase {
XCTAssertTrue(!launchCLIArgs.arguments.isEmpty)
XCTAssertEqual(launchCLIArgs.arguments[0].name, "MyLaunchArgument")
XCTAssertTrue(launchCLIArgs.arguments[0].enabled)
XCTAssertNil(scheme.launchAction?.customLLDBInitFile)
}

private func assert(minimalScheme scheme: XCScheme) {
Expand Down

0 comments on commit 5900fae

Please sign in to comment.