Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2710a72

Browse files
authored
Merge pull request yonaskolb#514 from elliottwilliams/emw_missing_files
Add missingFiles option to skip checking for config file existence
2 parents 65cc5f4 + 732d070 commit 2710a72

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Master
44

5+
#### Added
6+
- Added `missingConfigFiles` to `options.disabledValidations` to optionally skip checking for the existence of config files.
7+
58
## 2.2.0
69

710
#### Added

Docs/ProjectSpec.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Note that target names can also be changed by adding a `name` property to a targ
103103
- [ ] **deploymentTarget**: **[[Platform](#platform): String]** - A project wide deployment target can be specified for each platform otherwise the default SDK version in Xcode will be used. This will be overridden by any custom build settings that set the deployment target eg `IPHONEOS_DEPLOYMENT_TARGET`. Target specific deployment targets can also be set with [Target](#target).deploymentTarget.
104104
- [ ] **disabledValidations**: **[String]** - A list of validations that can be disabled if they're too strict for your use case. By default this is set to an empty array. Currently these are the available options:
105105
- `missingConfigs`: Disable errors for configurations in yaml files that don't exist in the project itself. This can be useful if you include the same yaml file in different projects
106+
- `missingConfigFiles`: Disable checking for the existence of configuration files. This can be useful for generating a project in a context where config files are not available.
106107
- [ ] **defaultConfig**: **String** - The default configuration for command line builds from Xcode. If the configuration provided here doesn't match one in your [configs](#configs) key, XcodeGen will fail. If you don't set this, the first configuration alphabetically will be chosen.
107108
- [ ] **groupSortPosition**: **String** - Where groups are sorted in relation to other files. Either:
108109
- `none` - sorted alphabetically with all the other files

Sources/ProjectSpec/SpecOptions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public struct SpecOptions: Equatable {
2323

2424
public enum ValidationType: String {
2525
case missingConfigs
26+
case missingConfigFiles
2627
}
2728

2829
public enum SettingPresets: String {

Sources/ProjectSpec/SpecValidation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extension Project {
5252
}
5353

5454
for (config, configFile) in configFiles {
55-
if !(basePath + configFile).exists {
55+
if !options.disabledValidations.contains(.missingConfigFiles) && !(basePath + configFile).exists {
5656
errors.append(.invalidConfigFile(configFile: configFile, config: config))
5757
}
5858
if !options.disabledValidations.contains(.missingConfigs) && getConfig(config) == nil {
@@ -73,7 +73,7 @@ extension Project {
7373
for target in projectTargets {
7474

7575
for (config, configFile) in target.configFiles {
76-
if !(basePath + configFile).exists {
76+
if !options.disabledValidations.contains(.missingConfigFiles) && !(basePath + configFile).exists {
7777
errors.append(.invalidTargetConfigFile(target: target.name, configFile: configFile, config: config))
7878
}
7979
if !options.disabledValidations.contains(.missingConfigs) && getConfig(config) == nil {

Tests/XcodeGenKitTests/ProjectSpecTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ class ProjectSpecTests: XCTestCase {
117117
project.configFiles = ["missingConfiguration": configPath.string]
118118
try project.validate()
119119
}
120+
121+
$0.it("allows non-existent config files") {
122+
var project = baseProject
123+
project.options = SpecOptions(disabledValidations: [.missingConfigFiles])
124+
project.configFiles = ["invalid": "doesntexist.xcconfig"]
125+
try project.validate()
126+
}
120127

121128
$0.it("fails with invalid target") {
122129
var project = baseProject

0 commit comments

Comments
 (0)