From c76c8a7672ea865e33817f9eefe00b4d99ea9060 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Wed, 31 Aug 2022 13:22:13 +0200 Subject: [PATCH 1/2] Make PUBLIC_HEADERS_FOLDER_PATH optional --- .../Commands/Postbuild/PostbuildContext.swift | 4 ++-- .../Commands/PostbuildContextTests.swift | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Sources/XCRemoteCache/Commands/Postbuild/PostbuildContext.swift b/Sources/XCRemoteCache/Commands/Postbuild/PostbuildContext.swift index 90dc0ea7..7466d4d6 100644 --- a/Sources/XCRemoteCache/Commands/Postbuild/PostbuildContext.swift +++ b/Sources/XCRemoteCache/Commands/Postbuild/PostbuildContext.swift @@ -140,8 +140,8 @@ extension PostbuildContext { /// Note: The file has yaml extension, even it is in the json format overlayHeadersPath = targetTempDir.appendingPathComponent("all-product-headers.yaml") irrelevantDependenciesPaths = config.irrelevantDependenciesPaths - let publicHeadersPath: String = try env.readEnv(key: "PUBLIC_HEADERS_FOLDER_PATH") - if publicHeadersPath != "/usr/local/include" { + let publicHeadersPathEnv: String? = env.readEnv(key: "PUBLIC_HEADERS_FOLDER_PATH") + if let publicHeadersPath = publicHeadersPathEnv, publicHeadersPathEnv != "/usr/local/include" { // '/usr/local/include' is a value of PUBLIC_HEADERS_FOLDER_PATH when no public headers are automatically // generated and it is up to a project configuration to place it in a common location (e.g. static library) publicHeadersFolderPath = builtProductsDir.appendingPathComponent(publicHeadersPath) diff --git a/Tests/XCRemoteCacheTests/Commands/PostbuildContextTests.swift b/Tests/XCRemoteCacheTests/Commands/PostbuildContextTests.swift index 38e3e779..725d26e3 100644 --- a/Tests/XCRemoteCacheTests/Commands/PostbuildContextTests.swift +++ b/Tests/XCRemoteCacheTests/Commands/PostbuildContextTests.swift @@ -150,4 +150,13 @@ class PostbuildContextTests: FileXCTestCase { XCTAssertEqual(context.publicHeadersFolderPath, "/MyBuiltProductsDir/MyModule.grameworks/Headers") } + + func testPublicHeaderFolderPathEnvIsOptional() throws { + var envs = Self.SampleEnvs + envs.removeValue(forKey: "PUBLIC_HEADERS_FOLDER_PATH") + + let context = try PostbuildContext(config, env: envs) + + XCTAssertNil(context.publicHeadersFolderPath) + } } From b1507b6e60a6b9005942291a3107d769fed21ea4 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Wed, 31 Aug 2022 13:42:30 +0200 Subject: [PATCH 2/2] Fix linting --- Tests/XCRemoteCacheTests/Commands/PostbuildContextTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/XCRemoteCacheTests/Commands/PostbuildContextTests.swift b/Tests/XCRemoteCacheTests/Commands/PostbuildContextTests.swift index 725d26e3..5703b3b8 100644 --- a/Tests/XCRemoteCacheTests/Commands/PostbuildContextTests.swift +++ b/Tests/XCRemoteCacheTests/Commands/PostbuildContextTests.swift @@ -150,7 +150,7 @@ class PostbuildContextTests: FileXCTestCase { XCTAssertEqual(context.publicHeadersFolderPath, "/MyBuiltProductsDir/MyModule.grameworks/Headers") } - + func testPublicHeaderFolderPathEnvIsOptional() throws { var envs = Self.SampleEnvs envs.removeValue(forKey: "PUBLIC_HEADERS_FOLDER_PATH")