Skip to content

Commit 46fb0d7

Browse files
macblazerfortmarekclaude
authored
feat: add optional debugAsWhichUser to XCScheme.LaunchAction (#1100)
* Add optional debugAsWhichUser to XCScheme.LaunchAction properties. * fix: remove trailing whitespace in XCSchemeTests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: fortmarek <marekfort@me.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c60786d commit 46fb0d7

4 files changed

Lines changed: 119 additions & 4 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "2640"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "XcodeProj"
19+
BuildableName = "XcodeProj"
20+
BlueprintName = "XcodeProj"
21+
ReferencedContainer = "container:">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Debug"
28+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
29+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30+
shouldUseLaunchSchemeArgsEnv = "YES">
31+
<Testables>
32+
</Testables>
33+
</TestAction>
34+
<LaunchAction
35+
buildConfiguration = "Debug"
36+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
37+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
38+
launchStyle = "0"
39+
useCustomWorkingDirectory = "NO"
40+
ignoresPersistentStateOnLaunch = "NO"
41+
debugDocumentVersioning = "YES"
42+
debugServiceExtension = "internal"
43+
allowLocationSimulation = "YES"
44+
debugAsWhichUser = "root">
45+
<BuildableProductRunnable
46+
runnableDebuggingMode = "0">
47+
<BuildableReference
48+
BuildableIdentifier = "primary"
49+
BlueprintIdentifier = "5CC725022DA91FB6004D43D4"
50+
BuildableName = "app_clip.app"
51+
BlueprintName = "app_clip"
52+
ReferencedContainer = "container:example.xcodeproj">
53+
</BuildableReference>
54+
</BuildableProductRunnable>
55+
</LaunchAction>
56+
<ProfileAction
57+
buildConfiguration = "Release"
58+
shouldUseLaunchSchemeArgsEnv = "YES"
59+
savedToolIdentifier = ""
60+
useCustomWorkingDirectory = "NO"
61+
debugDocumentVersioning = "YES">
62+
<MacroExpansion>
63+
<BuildableReference
64+
BuildableIdentifier = "primary"
65+
BlueprintIdentifier = "XcodeProj"
66+
BuildableName = "XcodeProj"
67+
BlueprintName = "XcodeProj"
68+
ReferencedContainer = "container:">
69+
</BuildableReference>
70+
</MacroExpansion>
71+
</ProfileAction>
72+
<AnalyzeAction
73+
buildConfiguration = "Debug">
74+
</AnalyzeAction>
75+
<ArchiveAction
76+
buildConfiguration = "Release"
77+
revealArchiveInOrganizer = "YES">
78+
</ArchiveAction>
79+
</Scheme>

Sources/XcodeProj/Extensions/AEXML+XcodeFormat.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ let attributesOrder: [String: [String]] = [
6262
"enableGPUFrameCaptureMode",
6363
"enableGPUValidationMode",
6464
"allowLocationSimulation",
65+
"debugAsWhichUser",
6566
"storeKitConfigurationFileReference",
6667
],
6768
"ProfileAction": [

Sources/XcodeProj/Scheme/XCScheme+LaunchAction.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public extension XCScheme {
8585
public var customLaunchCommand: String?
8686
public var customLLDBInitFile: String?
8787
public var appClipInvocationURLString: String?
88+
public var debugAsWhichUser: String?
8889

8990
// MARK: - Init
9091

@@ -128,7 +129,8 @@ public extension XCScheme {
128129
storeKitConfigurationFileReference: StoreKitConfigurationFileReference? = nil,
129130
customLaunchCommand: String? = nil,
130131
customLLDBInitFile: String? = nil,
131-
appClipInvocationURLString: String? = nil) {
132+
appClipInvocationURLString: String? = nil,
133+
debugAsWhichUser: String? = nil) {
132134
self.runnable = runnable
133135
self.macroExpansion = macroExpansion
134136
self.buildConfiguration = buildConfiguration
@@ -168,6 +170,7 @@ public extension XCScheme {
168170
self.customLaunchCommand = customLaunchCommand
169171
self.customLLDBInitFile = customLLDBInitFile
170172
self.appClipInvocationURLString = appClipInvocationURLString
173+
self.debugAsWhichUser = debugAsWhichUser
171174
super.init(preActions, postActions)
172175
}
173176

@@ -214,7 +217,8 @@ public extension XCScheme {
214217
storeKitConfigurationFileReference: StoreKitConfigurationFileReference? = nil,
215218
customLaunchCommand: String? = nil,
216219
customLLDBInitFile: String? = nil,
217-
appClipInvocationURLString: String? = nil
220+
appClipInvocationURLString: String? = nil,
221+
debugAsWhichUser: String? = nil
218222
) {
219223
self.init(
220224
runnable: pathRunnable,
@@ -257,7 +261,8 @@ public extension XCScheme {
257261
storeKitConfigurationFileReference: storeKitConfigurationFileReference,
258262
customLaunchCommand: customLaunchCommand,
259263
customLLDBInitFile: customLLDBInitFile,
260-
appClipInvocationURLString: appClipInvocationURLString
264+
appClipInvocationURLString: appClipInvocationURLString,
265+
debugAsWhichUser: debugAsWhichUser
261266
)
262267
}
263268

@@ -344,6 +349,7 @@ public extension XCScheme {
344349
}
345350

346351
appClipInvocationURLString = element.attributes["appClipInvocationURLString"]
352+
debugAsWhichUser = element.attributes["debugAsWhichUser"]
347353

348354
try super.init(element: element)
349355
}
@@ -414,6 +420,9 @@ public extension XCScheme {
414420
if let appClipInvocationURLString {
415421
attributes["appClipInvocationURLString"] = appClipInvocationURLString
416422
}
423+
if let debugAsWhichUser {
424+
attributes["debugAsWhichUser"] = debugAsWhichUser
425+
}
417426

418427
return attributes
419428
}
@@ -524,7 +533,8 @@ public extension XCScheme {
524533
storeKitConfigurationFileReference == rhs.storeKitConfigurationFileReference &&
525534
customLaunchCommand == rhs.customLaunchCommand &&
526535
customLLDBInitFile == rhs.customLLDBInitFile &&
527-
appClipInvocationURLString == rhs.appClipInvocationURLString
536+
appClipInvocationURLString == rhs.appClipInvocationURLString &&
537+
debugAsWhichUser == rhs.debugAsWhichUser
528538
}
529539
}
530540
}

Tests/XcodeProjTests/Scheme/XCSchemeTests.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,27 @@ final class XCSchemeIntegrationTests: XCTestCase {
7373
assertion: { assert(minimalScheme: $1) })
7474
}
7575

76+
func test_read_debugAsRootScheme() throws {
77+
let subject = try XCScheme(path: debugAsRootSchemePath)
78+
79+
XCTAssertNotNil(subject.launchAction)
80+
XCTAssertEqual(subject.launchAction?.debugAsWhichUser, "root")
81+
}
82+
83+
func test_write_debugAsRootScheme() throws {
84+
try testWrite(from: debugAsRootSchemePath,
85+
initModel: { try? XCScheme(path: $0) },
86+
modify: { $0 },
87+
assertion: { _, scheme in
88+
XCTAssertEqual(scheme.launchAction?.debugAsWhichUser, "root")
89+
})
90+
}
91+
92+
func test_read_write_debugAsRootScheme_produces_no_diff() throws {
93+
try testReadWriteProducesNoDiff(from: debugAsRootSchemePath,
94+
initModel: XCScheme.init(path:))
95+
}
96+
7697
func test_write_testableReferenceDefaultAttributesValuesAreOmitted() {
7798
let reference = XCScheme.TestableReference(
7899
skipped: false,
@@ -946,4 +967,8 @@ final class XCSchemeIntegrationTests: XCTestCase {
946967
private var appClipScheme: Path {
947968
fixturesPath() + "Schemes/AppClip.xcscheme"
948969
}
970+
971+
private var debugAsRootSchemePath: Path {
972+
fixturesPath() + "Schemes/DebugAsRoot.xcscheme"
973+
}
949974
}

0 commit comments

Comments
 (0)