diff --git a/Sources/XcodeProj/Extensions/AEXML+XcodeFormat.swift b/Sources/XcodeProj/Extensions/AEXML+XcodeFormat.swift index f19dd2001..aa1161f3d 100644 --- a/Sources/XcodeProj/Extensions/AEXML+XcodeFormat.swift +++ b/Sources/XcodeProj/Extensions/AEXML+XcodeFormat.swift @@ -43,6 +43,7 @@ let attributesOrder: [String: [String]] = [ "buildConfiguration", "selectedDebuggerIdentifier", "selectedLauncherIdentifier", + "customLLDBInitFile", "language", "region", "launchStyle", diff --git a/Tests/XcodeProjTests/Extensions/AEXML+XcodeFormatTests.swift b/Tests/XcodeProjTests/Extensions/AEXML+XcodeFormatTests.swift index 529a82c31..cb4ea0284 100644 --- a/Tests/XcodeProjTests/Extensions/AEXML+XcodeFormatTests.swift +++ b/Tests/XcodeProjTests/Extensions/AEXML+XcodeFormatTests.swift @@ -10,7 +10,7 @@ extension String { } class AEXML_XcodeFormatTests: XCTestCase { - private let expectedXml = + private let expectedBuildActionXml = """ """ + private let expectedLaunchActionXml = + """ + + + + """ + func test_BuildAction_attributes_sorted_when_original_sorted() { - validateAttributes(attributes: [ - "parallelizeBuildables": "YES", - "runPostActionsOnFailure": "YES", - "buildImplicitDependencies": "NO", - ]) + validateAttributes( + expectedXML: expectedBuildActionXml.cleaned, + childName: "BuildAction", + attributes: [ + "parallelizeBuildables": "YES", + "runPostActionsOnFailure": "YES", + "buildImplicitDependencies": "NO", + ] + ) } func test_BuildAction_attributes_sorted_when_original_unsorted() { - validateAttributes(attributes: [ - "buildImplicitDependencies": "NO", - "parallelizeBuildables": "YES", - "runPostActionsOnFailure": "YES", - ]) + validateAttributes( + expectedXML: expectedBuildActionXml.cleaned, + childName: "BuildAction", + attributes: [ + "buildImplicitDependencies": "NO", + "parallelizeBuildables": "YES", + "runPostActionsOnFailure": "YES", + ] + ) + } + + func test_LaunchAction_attributes_sorted_when_original_sorted() { + validateAttributes( + expectedXML: expectedLaunchActionXml.cleaned, + childName: "LaunchAction", + attributes: [ + "buildConfiguration": "Debug", + "selectedLauncherIdentifier": "Xcode.DebuggerFoundation.Launcher.LLDB", + "customLLDBInitFile": "$(BAZEL_LLDB_INIT)", + "launchStyle": "0", + "allowLocationSimulation": "YES" + ] + ) + } + + func test_LaunchAction_attributes_sorted_when_original_unsorted() { + validateAttributes( + expectedXML: expectedLaunchActionXml.cleaned, + childName: "LaunchAction", + attributes: [ + "customLLDBInitFile": "$(BAZEL_LLDB_INIT)", + "allowLocationSimulation": "YES", + "buildConfiguration": "Debug", + "selectedLauncherIdentifier": "Xcode.DebuggerFoundation.Launcher.LLDB", + "launchStyle": "0", + ] + ) } - func validateAttributes(attributes: [String: String], line: UInt = #line) { + func validateAttributes( + expectedXML: String, + childName: String, + attributes: [String: String], + line: UInt = #line + ) { let document = AEXMLDocument() - let child = document.addChild(name: "BuildAction") + let child = document.addChild(name: childName) child.attributes = attributes let result = document.xmlXcodeFormat - XCTAssertEqual(expectedXml.cleaned, result.cleaned, line: line) + XCTAssertEqual(result.cleaned, expectedXML, line: line) } }