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..5703b3b8 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) + } }