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

Fix bug: if RemoteRunnable doesn't contains BuildableReference XcodeProj removes xcscheme file #627

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
Fix bug: if RemoteRunnable doesn't contains BuildableReference Xc…
…odeProj removes xcscheme file

Closes #626
  • Loading branch information
Daniil Subbotin committed Jul 29, 2021
commit ec8a69b20cb534d48963b390f024942b16ed7f4f
98 changes: 98 additions & 0 deletions Fixtures/Schemes/RunnableWithoutBuildableReference.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1230"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FE7C11D21B6DB70D0041DF02"
BuildableName = "Ava.app"
BlueprintName = "core-ava"
ReferencedContainer = "container:core-ava.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9942115E25C4D3B7000711CE"
BuildableName = "AvaTests.xctest"
BlueprintName = "AvaTests"
ReferencedContainer = "container:core-ava.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Staging"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
askForAppToLaunch = "Yes"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
launchAutomaticallySubstyle = "2">
<RemoteRunnable
runnableDebuggingMode = "1"
BundleIdentifier = "me.ava.Ava-Staging"
RemotePath = "/var/containers/Bundle/Application/018F0933-05E8-4359-9955-39E0523C4246/Ava.app">
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FE7C11D21B6DB70D0041DF02"
BuildableName = "Ava.app"
BlueprintName = "core-ava"
ReferencedContainer = "container:core-ava.xcodeproj">
</BuildableReference>
</MacroExpansion>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FE7C11D21B6DB70D0041DF02"
BuildableName = "Ava.app"
BlueprintName = "core-ava"
ReferencedContainer = "container:core-ava.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion Sources/XcodeProj/Scheme/XCScheme+LaunchAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ extension XCScheme {
selectedDebuggerIdentifier = element.attributes["selectedDebuggerIdentifier"] ?? XCScheme.defaultDebugger
selectedLauncherIdentifier = element.attributes["selectedLauncherIdentifier"] ?? XCScheme.defaultLauncher
launchStyle = element.attributes["launchStyle"].flatMap { Style(rawValue: $0) } ?? .auto
askForAppToLaunch = element.attributes["askForAppToLaunch"].map { $0 == "YES" }
askForAppToLaunch = element.attributes["askForAppToLaunch"].map { $0 == "YES" || $0 == "Yes" }
useCustomWorkingDirectory = element.attributes["useCustomWorkingDirectory"] == "YES"
ignoresPersistentStateOnLaunch = element.attributes["ignoresPersistentStateOnLaunch"] == "YES"
debugDocumentVersioning = element.attributes["debugDocumentVersioning"].map { $0 == "YES" } ?? true
Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodeProj/Scheme/XCScheme+ProfileAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extension XCScheme {
savedToolIdentifier = element.attributes["savedToolIdentifier"] ?? ""
useCustomWorkingDirectory = element.attributes["useCustomWorkingDirectory"] == "YES"
debugDocumentVersioning = element.attributes["debugDocumentVersioning"].map { $0 == "YES" } ?? true
askForAppToLaunch = element.attributes["askForAppToLaunch"].map { $0 == "YES" }
askForAppToLaunch = element.attributes["askForAppToLaunch"].map { $0 == "YES" || $0 == "Yes" }
ignoresPersistentStateOnLaunch = element.attributes["ignoresPersistentStateOnLaunch"].map { $0 == "YES" } ?? false

let buildableProductRunnableElement = element["BuildableProductRunnable"]
Expand Down
8 changes: 5 additions & 3 deletions Sources/XcodeProj/Scheme/XCScheme+Runnable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extension XCScheme {
// MARK: - Attributes

public var runnableDebuggingMode: String
public var buildableReference: BuildableReference
public var buildableReference: BuildableReference?

// MARK: - Init

Expand All @@ -18,7 +18,7 @@ extension XCScheme {

init(element: AEXMLElement) throws {
runnableDebuggingMode = element.attributes["runnableDebuggingMode"] ?? "0"
buildableReference = try BuildableReference(element: element["BuildableReference"])
buildableReference = try? BuildableReference(element: element["BuildableReference"])
}

// MARK: - XML
Expand All @@ -27,7 +27,9 @@ extension XCScheme {
let element = AEXMLElement(name: "Runnable",
value: nil,
attributes: ["runnableDebuggingMode": runnableDebuggingMode])
element.addChild(buildableReference.xmlElement())
if let buildableReference = buildableReference {
element.addChild(buildableReference.xmlElement())
}
return element
}

Expand Down
Loading