Unable to exclude specific headers from a target

SPM doesn't allow to exclude specific header from a target.
Moreover, it doesn't allow to exclude a folder with a headers from a target.

Is it possible to use ( unsafe flag? ) to exclude header?

Do you mean excluding as a public header? You control that yourself by what you place in the include directory or whatever directory you are referencing with publicHeaderPath.

It depends. For example, library can be added as submodule and I can copy only a SPM package file into a directory to use it. So, I only need to keep ( separately ) a correct version of spm file.

Moreover, if CMake wants to add a support for SPM, it may need some instructions to add only one set of files to a target. ( Yeah, it doesn't make sense at all, because all these headers are only a cosmetic change for targets and compliers know where to find correct headers even if they are not included in targets ).

This seems to be the same as [SR-14456] Provide a way to exclude specific headers under `include` from the module map · Issue #4440 · apple/swift-package-manager · GitHub. I've been considering this one, and it seems to me that SwiftPM should apply any paths listed in excludes to the module map it creates for the Clang target. That should have the effect of making those headers invisible to the clients. Does that sound like a reasonable approach in this case?

1 Like

Currently I have the same issue when importing GitHub - KhronosGroup/SPIRV-Cross: SPIRV-Cross is a practical tool and library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages.. I am trying to exclude include directory in Package.swift, but SPM still looks into this folder.