diff --git a/Plugins/RswiftGenerateResourcesCommand/RswiftGenerateResourcesCommand.swift b/Plugins/RswiftGenerateResourcesCommand/RswiftGenerateResourcesCommand.swift index a9b05815..549a1a75 100644 --- a/Plugins/RswiftGenerateResourcesCommand/RswiftGenerateResourcesCommand.swift +++ b/Plugins/RswiftGenerateResourcesCommand/RswiftGenerateResourcesCommand.swift @@ -101,21 +101,20 @@ struct ParsedArguments { static func parse(arguments: [String]) -> ParsedArguments { var result = ParsedArguments() - - for (key, value) in zip(arguments, arguments.dropFirst()) { - if result.outputFile == nil && key.hasSuffix(".swift") { - result.outputFile = key - continue - } - if result.outputFile == nil && value.hasSuffix(".swift") { - result.outputFile = value - continue - } - - if key == "--target" { - result.targets.append(value) - } else if value != "--target" { - result.remaining.append(value) + var index = 0 + + while index < arguments.count { + let arg = arguments[index] + + if arg == "--target", index + 1 < arguments.count { + result.targets.append(arguments[index + 1]) + index += 2 + } else if arg.hasSuffix(".swift") { + result.outputFile = arg + index += 1 + } else { + result.remaining.append(arg) + index += 1 } }