From dad3408f78d65ff5ca7322ef44891b94d3d5a7c3 Mon Sep 17 00:00:00 2001 From: Pyae Phyo MS Date: Mon, 7 Jun 2021 22:50:58 +0800 Subject: [PATCH] Add support for directories/files names with spaces --- .../SwiftShieldCore/ProjectRunner/SchemeInfoProvider.swift | 2 +- Sources/SwiftShieldCore/StringHelpers.swift | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftShieldCore/ProjectRunner/SchemeInfoProvider.swift b/Sources/SwiftShieldCore/ProjectRunner/SchemeInfoProvider.swift index 275137a..f50a1d3 100644 --- a/Sources/SwiftShieldCore/ProjectRunner/SchemeInfoProvider.swift +++ b/Sources/SwiftShieldCore/ProjectRunner/SchemeInfoProvider.swift @@ -85,7 +85,7 @@ struct SchemeInfoProvider: SchemeInfoProviderProtocol { if let swiftFileList = swiftFileList { let swiftFilePaths = try swiftFileList.read() .components(separatedBy: "\n") - .filter { !$0.isEmpty } + .filter { !$0.isEmpty }.map{ $0.removeEscapedSpaces } if let complieFlagIndex = compilerArguments.firstIndex(of: "-c") { var insertIndex = complieFlagIndex diff --git a/Sources/SwiftShieldCore/StringHelpers.swift b/Sources/SwiftShieldCore/StringHelpers.swift index 9494299..47bd8f3 100644 --- a/Sources/SwiftShieldCore/StringHelpers.swift +++ b/Sources/SwiftShieldCore/StringHelpers.swift @@ -46,6 +46,10 @@ extension String { var replacingEscapedSpaces: String { replacingOccurrences(of: "\\ ", with: spacedFolderPlaceholder) } + + var removeEscapedSpaces: String { + replacingOccurrences(of: "\\ ", with: " ") + } var removingPlaceholder: String { replacingOccurrences(of: spacedFolderPlaceholder, with: " ")