Merge pull request #514 from elliottwilliams/emw_missing_files

Add missingFiles option to skip checking for config file existence
This commit is contained in:
Yonas Kolb
2019-02-13 12:49:30 +11:00
committed by GitHub
5 changed files with 14 additions and 2 deletions
+3
View File
@@ -2,6 +2,9 @@
## Master
#### Added
- Added `missingConfigFiles` to `options.disabledValidations` to optionally skip checking for the existence of config files.
## 2.2.0
#### Added
+1
View File
@@ -103,6 +103,7 @@ Note that target names can also be changed by adding a `name` property to a targ
- [ ] **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.
- [ ] **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:
- `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
- `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.
- [ ] **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.
- [ ] **groupSortPosition**: **String** - Where groups are sorted in relation to other files. Either:
- `none` - sorted alphabetically with all the other files
+1
View File
@@ -23,6 +23,7 @@ public struct SpecOptions: Equatable {
public enum ValidationType: String {
case missingConfigs
case missingConfigFiles
}
public enum SettingPresets: String {
+2 -2
View File
@@ -52,7 +52,7 @@ extension Project {
}
for (config, configFile) in configFiles {
if !(basePath + configFile).exists {
if !options.disabledValidations.contains(.missingConfigFiles) && !(basePath + configFile).exists {
errors.append(.invalidConfigFile(configFile: configFile, config: config))
}
if !options.disabledValidations.contains(.missingConfigs) && getConfig(config) == nil {
@@ -73,7 +73,7 @@ extension Project {
for target in projectTargets {
for (config, configFile) in target.configFiles {
if !(basePath + configFile).exists {
if !options.disabledValidations.contains(.missingConfigFiles) && !(basePath + configFile).exists {
errors.append(.invalidTargetConfigFile(target: target.name, configFile: configFile, config: config))
}
if !options.disabledValidations.contains(.missingConfigs) && getConfig(config) == nil {
@@ -117,6 +117,13 @@ class ProjectSpecTests: XCTestCase {
project.configFiles = ["missingConfiguration": configPath.string]
try project.validate()
}
$0.it("allows non-existent config files") {
var project = baseProject
project.options = SpecOptions(disabledValidations: [.missingConfigFiles])
project.configFiles = ["invalid": "doesntexist.xcconfig"]
try project.validate()
}
$0.it("fails with invalid target") {
var project = baseProject