diff --git a/R.swift/Util/IgnoreFile.swift b/R.swift/Util/IgnoreFile.swift index 2ff68475..c1c75aac 100644 --- a/R.swift/Util/IgnoreFile.swift +++ b/R.swift/Util/IgnoreFile.swift @@ -10,6 +10,10 @@ import Foundation class IgnoreFile { private let patterns: [String] + + init() { + patterns = [] + } init(ignoreFileURL: URL) throws { let ignoreFileParentPath = ignoreFileURL.baseURL?.absoluteString ?? "" diff --git a/R.swift/main.swift b/R.swift/main.swift index 1aa5ee25..bf172180 100644 --- a/R.swift/main.swift +++ b/R.swift/main.swift @@ -13,13 +13,6 @@ let IndentationString = " " let ResourceFilename = "R.generated.swift" var isEdgeEnabled = false -private func isValidURL(ignoreFile : IgnoreFile?, url: NSURL) -> Bool { - if let ignoreFile = ignoreFile { - return !ignoreFile.match(url: url) - } else { - return true - } -} do { let callInformation = try CallInformation(processInfo: ProcessInfo()) @@ -27,15 +20,17 @@ do { let xcodeproj = try Xcodeproj(url: callInformation.xcodeprojURL) - var ignoreFile : IgnoreFile? = nil + let ignoreFile : IgnoreFile if let rswiftignoreURL = callInformation.rswiftignoreURL { ignoreFile = try IgnoreFile(ignoreFileURL: rswiftignoreURL) + } else { + ignoreFile = IgnoreFile() } let resourceURLs = try xcodeproj.resourcePathsForTarget(callInformation.targetName) .map(pathResolver(with: callInformation.URLForSourceTreeFolder)) .flatMap { $0 } - .filter { isValidURL(ignoreFile: ignoreFile, url: $0 as NSURL) } + .filter { !ignoreFile.match(url: $0 as NSURL) } let resources = Resources(resourceURLs: resourceURLs, fileManager: FileManager.default)