Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode plugin support #740

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/Frontend/Commands/ScanCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions Sources/Shared/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -400,6 +409,7 @@ public final class Configuration {
$strict.reset()
$indexStorePath.reset()
$skipBuild.reset()
$skipSchemesValidation.reset()
$cleanBuild.reset()
$buildArguments.reset()
$xcodeListArguments.reset()
Expand Down
22 changes: 14 additions & 8 deletions Sources/XcodeSupport/XcodeProjectDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>

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(
Expand Down
Loading