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
Changes from 1 commit
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
Next Next commit
Added ability to skip schemes validation for Xcode projects
rock88 committed May 19, 2024
commit 1e1db483e9a395afdb10c5c5dfd3570e3b46d3d7
4 changes: 4 additions & 0 deletions Sources/Frontend/Commands/ScanCommand.swift
Original file line number Diff line number Diff line change
@@ -99,6 +99,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

@@ -161,6 +164,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)
10 changes: 10 additions & 0 deletions Sources/Shared/Configuration.swift
Original file line number Diff line number Diff line change
@@ -104,6 +104,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

@@ -239,6 +242,10 @@ public final class Configuration {
config[$skipBuild.key] = skipBuild
}

if $skipSchemesValidation.hasNonDefaultValue {
config[$skipSchemesValidation.key] = skipSchemesValidation
}

if $cleanBuild.hasNonDefaultValue {
config[$cleanBuild.key] = cleanBuild
}
@@ -336,6 +343,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:
@@ -382,6 +391,7 @@ public final class Configuration {
$strict.reset()
$indexStorePath.reset()
$skipBuild.reset()
$skipSchemesValidation.reset()
$cleanBuild.reset()
$buildArguments.reset()
$relativeResults.reset()
16 changes: 11 additions & 5 deletions Sources/XcodeSupport/XcodeProjectDriver.swift
Original file line number Diff line number Diff line change
@@ -46,12 +46,18 @@ 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().filter { configuration.schemes.contains($0) }
let validSchemeNames = schemes.mapSet { $0 }
let schemes: Set<String>

if let scheme = Set(configuration.schemes).subtracting(validSchemeNames).first {
throw PeripheryError.invalidScheme(name: scheme, project: project.path.lastComponent?.string ?? "")
if configuration.skipSchemesValidation {
schemes = Set(configuration.schemes)
} else {
// Ensure schemes exist within the project
schemes = try project.schemes().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(