diff --git a/CHANGELOG.md b/CHANGELOG.md index faeaa6e1..909d068a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index e43f0e9c..c533bbe7 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -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 diff --git a/Sources/ProjectSpec/SpecOptions.swift b/Sources/ProjectSpec/SpecOptions.swift index 4fe36f22..b966be9d 100644 --- a/Sources/ProjectSpec/SpecOptions.swift +++ b/Sources/ProjectSpec/SpecOptions.swift @@ -23,6 +23,7 @@ public struct SpecOptions: Equatable { public enum ValidationType: String { case missingConfigs + case missingConfigFiles } public enum SettingPresets: String { diff --git a/Sources/ProjectSpec/SpecValidation.swift b/Sources/ProjectSpec/SpecValidation.swift index bbecdfba..ab7c94c3 100644 --- a/Sources/ProjectSpec/SpecValidation.swift +++ b/Sources/ProjectSpec/SpecValidation.swift @@ -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 { diff --git a/Tests/XcodeGenKitTests/ProjectSpecTests.swift b/Tests/XcodeGenKitTests/ProjectSpecTests.swift index 6eace70c..cc5d6eef 100644 --- a/Tests/XcodeGenKitTests/ProjectSpecTests.swift +++ b/Tests/XcodeGenKitTests/ProjectSpecTests.swift @@ -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