From bd1897a947d8391fc8b0d4879729652034292610 Mon Sep 17 00:00:00 2001 From: Adam Khazi Date: Wed, 24 Jul 2019 08:58:37 +0100 Subject: [PATCH] Do Not Create `Derived/InfoPlists` Folder When No InfoPlist Dictionary Specified (#456) * fix and test case * make info plist inclusion explicit * swiftformat and changelog --- CHANGELOG.md | 1 + .../Generator/DerivedFileGenerator.swift | 2 +- .../Generator/DerivedFileGeneratorTests.swift | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7a12f422..0b1aa0819 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/ - Ensuring transitive SDK dependencies are added correctly https://github.com/tuist/tuist/pull/441 by @adamkhazi - Ensuring the correct platform SDK dependencies path is set https://github.com/tuist/tuist/pull/419 by @kwridan - Update manifest target name such that its product has a valid name https://github.com/tuist/tuist/pull/426 by @kwridan +- Do not create `Derived/InfoPlists` folder when no InfoPlist dictionary is specified https://github.com/tuist/tuist/pull/456 by @adamkhazi ### Changed diff --git a/Sources/TuistGenerator/Generator/DerivedFileGenerator.swift b/Sources/TuistGenerator/Generator/DerivedFileGenerator.swift index 6ba9f5c1b..62c9eb7b1 100644 --- a/Sources/TuistGenerator/Generator/DerivedFileGenerator.swift +++ b/Sources/TuistGenerator/Generator/DerivedFileGenerator.swift @@ -70,7 +70,7 @@ final class DerivedFileGenerator: DerivedFileGenerating { } let toDelete = Set(existing).subtracting(new) - if !fileHandler.exists(infoPlistsPath) { + if !fileHandler.exists(infoPlistsPath), !targetsWithGeneratableInfoPlists.isEmpty { try fileHandler.createFolder(infoPlistsPath) } diff --git a/Tests/TuistGeneratorTests/Generator/DerivedFileGeneratorTests.swift b/Tests/TuistGeneratorTests/Generator/DerivedFileGeneratorTests.swift index ee0642ca2..1caf73675 100644 --- a/Tests/TuistGeneratorTests/Generator/DerivedFileGeneratorTests.swift +++ b/Tests/TuistGeneratorTests/Generator/DerivedFileGeneratorTests.swift @@ -54,4 +54,21 @@ final class DerivedFileGeneratorTests: XCTestCase { // Then XCTAssertFalse(fileHandler.exists(oldPlistPath)) } + + func test_generate_checkFolderNotCreated_whenNoGeneratedInfoPlist() throws { + // Given + let sourceRootPath = fileHandler.currentPath + let target = Target.test(name: "Target", infoPlist: .file(path: "/Info.plist")) + let project = Project.test(name: "App", targets: [target]) + let infoPlistsPath = DerivedFileGenerator.infoPlistsPath(sourceRootPath: sourceRootPath) + let path = infoPlistsPath.appending(component: "Target.plist") + + // When + _ = try subject.generate(project: project, + sourceRootPath: sourceRootPath) + + // Then + XCTAssertFalse(fileHandler.exists(path)) + XCTAssertFalse(fileHandler.exists(infoPlistsPath)) + } }