From c07f016f4df69f3e5b70f1b1bbd942dfbb420f30 Mon Sep 17 00:00:00 2001 From: Yonas Kolb Date: Tue, 26 Feb 2019 23:32:46 +1100 Subject: [PATCH 1/3] fix error on optional sources --- Sources/XcodeGenKit/SourceGenerator.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index 7e3d94c8..7e283967 100644 --- a/Sources/XcodeGenKit/SourceGenerator.swift +++ b/Sources/XcodeGenKit/SourceGenerator.swift @@ -463,6 +463,11 @@ class SourceGenerator { /// creates source files private func getSourceFiles(targetType: PBXProductType, targetSource: TargetSource, path: Path) throws -> [SourceFile] { + if targetSource.optional && !Path(targetSource.path).exists { + // Is optional so if it doesn't exist just return an empty array + return [] + } + // generate excluded paths targetSourceExcludePaths = getSourceExcludes(targetSource: targetSource) From 0b49bdb91f9c86bd84c46c397addf1b941eed9fc Mon Sep 17 00:00:00 2001 From: Yonas Kolb Date: Tue, 26 Feb 2019 23:34:52 +1100 Subject: [PATCH 2/3] add optional source to Fixture --- Tests/Fixtures/TestProject/project.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/Fixtures/TestProject/project.yml b/Tests/Fixtures/TestProject/project.yml index 3daa58ec..af92fe59 100644 --- a/Tests/Fixtures/TestProject/project.yml +++ b/Tests/Fixtures/TestProject/project.yml @@ -41,6 +41,8 @@ targets: - path: App_macOS - path: StandaloneFiles/Standalone.swift - path: Vendor/SomeXPCService.xpc + - path: NonExisting + optional: true dependencies: - target: Framework_macOS - target: XPC Service From d037527b82556f6ebbbb6e525130024fdcf1c278 Mon Sep 17 00:00:00 2001 From: Yonas Kolb Date: Wed, 27 Feb 2019 22:51:44 +1100 Subject: [PATCH 3/3] updated changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbcd1867..b581d2e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,12 @@ ## Master #### Added - - Added `missingConfigFiles` to `options.disabledValidations` to optionally skip checking for the existence of config files. - Added ability to automatically include Carthage related dependencies via `includeRelated: true` [#506](https://github.com/yonaskolb/XcodeGen/pull/506) @rpassis #### Fixed - Sources outside a project spec's directory will be correctly referenced as relative paths in the project file. [#524](https://github.com/yonaskolb/XcodeGen/pull/524) +- Fixed error when `optional` path is missing [#527](https://github.com/yonaskolb/XcodeGen/pull/527) @yonaskolb ## 2.2.0