Skip to content

Commit 7386710

Browse files
authored
Added ability to skip schemes validation for Xcode projects (#740)
1 parent 76e45c6 commit 7386710

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

Sources/Frontend/Commands/ScanCommand.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ struct ScanCommand: FrontendCommand {
102102
@Flag(help: "Skip the project build step")
103103
var skipBuild: Bool = defaultConfiguration.$skipBuild.defaultValue
104104

105+
@Flag(help: "Skip schemes validation")
106+
var skipSchemesValidation: Bool = defaultConfiguration.$skipSchemesValidation.defaultValue
107+
105108
@Flag(help: "Output result paths relative to the current directory")
106109
var relativeResults: Bool = defaultConfiguration.$relativeResults.defaultValue
107110

@@ -164,6 +167,7 @@ struct ScanCommand: FrontendCommand {
164167
configuration.apply(\.$strict, strict)
165168
configuration.apply(\.$indexStorePath, indexStorePath)
166169
configuration.apply(\.$skipBuild, skipBuild)
170+
configuration.apply(\.$skipSchemesValidation, skipSchemesValidation)
167171
configuration.apply(\.$cleanBuild, cleanBuild)
168172
configuration.apply(\.$buildArguments, buildArguments)
169173
configuration.apply(\.$relativeResults, relativeResults)

Sources/Shared/Configuration.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ public final class Configuration {
110110
@Setting(key: "skip_build", defaultValue: false)
111111
public var skipBuild: Bool
112112

113+
@Setting(key: "skip_schemes_validation", defaultValue: false)
114+
public var skipSchemesValidation: Bool
115+
113116
@Setting(key: "clean_build", defaultValue: false)
114117
public var cleanBuild: Bool
115118

@@ -245,6 +248,10 @@ public final class Configuration {
245248
config[$skipBuild.key] = skipBuild
246249
}
247250

251+
if $skipSchemesValidation.hasNonDefaultValue {
252+
config[$skipSchemesValidation.key] = skipSchemesValidation
253+
}
254+
248255
if $cleanBuild.hasNonDefaultValue {
249256
config[$cleanBuild.key] = cleanBuild
250257
}
@@ -350,6 +357,8 @@ public final class Configuration {
350357
$indexStorePath.assign(value)
351358
case $skipBuild.key:
352359
$skipBuild.assign(value)
360+
case $skipSchemesValidation.key:
361+
$skipSchemesValidation.assign(value)
353362
case $cleanBuild.key:
354363
$cleanBuild.assign(value)
355364
case $buildArguments.key:
@@ -400,6 +409,7 @@ public final class Configuration {
400409
$strict.reset()
401410
$indexStorePath.reset()
402411
$skipBuild.reset()
412+
$skipSchemesValidation.reset()
403413
$cleanBuild.reset()
404414
$buildArguments.reset()
405415
$xcodeListArguments.reset()

Sources/XcodeSupport/XcodeProjectDriver.swift

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,20 @@ public final class XcodeProjectDriver {
4646
throw PeripheryError.invalidTargets(names: invalidTargetNames.sorted(), project: project.path.lastComponent?.string ?? "")
4747
}
4848

49-
// Ensure schemes exist within the project
50-
let schemes = try project.schemes(
51-
additionalArguments: configuration.xcodeListArguments
52-
).filter { configuration.schemes.contains($0) }
53-
let validSchemeNames = schemes.mapSet { $0 }
54-
55-
if let scheme = Set(configuration.schemes).subtracting(validSchemeNames).first {
56-
throw PeripheryError.invalidScheme(name: scheme, project: project.path.lastComponent?.string ?? "")
49+
let schemes: Set<String>
50+
51+
if configuration.skipSchemesValidation {
52+
schemes = Set(configuration.schemes)
53+
} else {
54+
// Ensure schemes exist within the project
55+
schemes = try project.schemes(
56+
additionalArguments: configuration.xcodeListArguments
57+
).filter { configuration.schemes.contains($0) }
58+
let validSchemeNames = schemes.mapSet { $0 }
59+
60+
if let scheme = Set(configuration.schemes).subtracting(validSchemeNames).first {
61+
throw PeripheryError.invalidScheme(name: scheme, project: project.path.lastComponent?.string ?? "")
62+
}
5763
}
5864

5965
return self.init(

0 commit comments

Comments
 (0)