diff --git a/Sources/Frontend/Commands/ScanCommand.swift b/Sources/Frontend/Commands/ScanCommand.swift index ccf9fb582..e90b90bb4 100644 --- a/Sources/Frontend/Commands/ScanCommand.swift +++ b/Sources/Frontend/Commands/ScanCommand.swift @@ -102,6 +102,9 @@ struct ScanCommand: FrontendCommand { @Flag(help: "Skip the project build step") var skipBuild: Bool = defaultConfiguration.$skipBuild.defaultValue + @Flag(help: "Skip schemes validation") + var skipSchemesValidation: Bool = defaultConfiguration.$skipSchemesValidation.defaultValue + @Flag(help: "Output result paths relative to the current directory") var relativeResults: Bool = defaultConfiguration.$relativeResults.defaultValue @@ -164,6 +167,7 @@ struct ScanCommand: FrontendCommand { configuration.apply(\.$strict, strict) configuration.apply(\.$indexStorePath, indexStorePath) configuration.apply(\.$skipBuild, skipBuild) + configuration.apply(\.$skipSchemesValidation, skipSchemesValidation) configuration.apply(\.$cleanBuild, cleanBuild) configuration.apply(\.$buildArguments, buildArguments) configuration.apply(\.$relativeResults, relativeResults) diff --git a/Sources/Shared/Configuration.swift b/Sources/Shared/Configuration.swift index 30543f1da..9204b2b91 100644 --- a/Sources/Shared/Configuration.swift +++ b/Sources/Shared/Configuration.swift @@ -110,6 +110,9 @@ public final class Configuration { @Setting(key: "skip_build", defaultValue: false) public var skipBuild: Bool + @Setting(key: "skip_schemes_validation", defaultValue: false) + public var skipSchemesValidation: Bool + @Setting(key: "clean_build", defaultValue: false) public var cleanBuild: Bool @@ -245,6 +248,10 @@ public final class Configuration { config[$skipBuild.key] = skipBuild } + if $skipSchemesValidation.hasNonDefaultValue { + config[$skipSchemesValidation.key] = skipSchemesValidation + } + if $cleanBuild.hasNonDefaultValue { config[$cleanBuild.key] = cleanBuild } @@ -350,6 +357,8 @@ public final class Configuration { $indexStorePath.assign(value) case $skipBuild.key: $skipBuild.assign(value) + case $skipSchemesValidation.key: + $skipSchemesValidation.assign(value) case $cleanBuild.key: $cleanBuild.assign(value) case $buildArguments.key: @@ -400,6 +409,7 @@ public final class Configuration { $strict.reset() $indexStorePath.reset() $skipBuild.reset() + $skipSchemesValidation.reset() $cleanBuild.reset() $buildArguments.reset() $xcodeListArguments.reset() diff --git a/Sources/XcodeSupport/XcodeProjectDriver.swift b/Sources/XcodeSupport/XcodeProjectDriver.swift index bb0245da0..c085315ca 100644 --- a/Sources/XcodeSupport/XcodeProjectDriver.swift +++ b/Sources/XcodeSupport/XcodeProjectDriver.swift @@ -46,14 +46,20 @@ public final class XcodeProjectDriver { throw PeripheryError.invalidTargets(names: invalidTargetNames.sorted(), project: project.path.lastComponent?.string ?? "") } - // Ensure schemes exist within the project - let schemes = try project.schemes( - additionalArguments: configuration.xcodeListArguments - ).filter { configuration.schemes.contains($0) } - let validSchemeNames = schemes.mapSet { $0 } - - if let scheme = Set(configuration.schemes).subtracting(validSchemeNames).first { - throw PeripheryError.invalidScheme(name: scheme, project: project.path.lastComponent?.string ?? "") + let schemes: Set + + if configuration.skipSchemesValidation { + schemes = Set(configuration.schemes) + } else { + // Ensure schemes exist within the project + schemes = try project.schemes( + additionalArguments: configuration.xcodeListArguments + ).filter { configuration.schemes.contains($0) } + let validSchemeNames = schemes.mapSet { $0 } + + if let scheme = Set(configuration.schemes).subtracting(validSchemeNames).first { + throw PeripheryError.invalidScheme(name: scheme, project: project.path.lastComponent?.string ?? "") + } } return self.init(