# Unable to exclude specific headers from a target

**URL:** <https://forums.swift.org/t/unable-to-exclude-specific-headers-from-a-target/51017>\
**Category:** Using Swift\
**Tags:** packagemanager\
**Created:** [August 7, 2021, 11:53am UTC](https://forums.swift.org/t/unable-to-exclude-specific-headers-from-a-target/51017 "2021-08-07T11:53:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lolgear](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lolgear/32/4790_2.png) [@lolgear](https://forums.swift.org/u/lolgear)\
**Post date:** [August 7, 2021, 11:53am UTC](https://forums.swift.org/t/unable-to-exclude-specific-headers-from-a-target/51017/1 "2021-08-07T11:53:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![NeoNacho](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/neonacho/32/1368_2.png) [@NeoNacho](https://forums.swift.org/u/NeoNacho)\
**Post date:** [August 12, 2021, 12:03am UTC](https://forums.swift.org/t/unable-to-exclude-specific-headers-from-a-target/51017/2 "2021-08-12T00:03:31Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![lolgear](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lolgear/32/4790_2.png) [@lolgear](https://forums.swift.org/u/lolgear)\
**Post date:** [August 16, 2021, 2:55pm UTC](https://forums.swift.org/t/unable-to-exclude-specific-headers-from-a-target/51017/3 "2021-08-16T14:55:17Z")

</div>

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 ).

---

<div class="post-metadata">

**Author:** ![abertelrud](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@abertelrud](https://forums.swift.org/u/abertelrud)\
**Post date:** [August 16, 2021, 5:28pm UTC](https://forums.swift.org/t/unable-to-exclude-specific-headers-from-a-target/51017/4 "2021-08-16T17:28:46Z")

</div>

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](https://bugs.swift.org/browse/SR-14456). 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?

---

<div class="post-metadata">

**Author:** ![SpectralDragon](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/spectraldragon/32/5035_2.png) [@SpectralDragon](https://forums.swift.org/u/SpectralDragon)\
**Post date:** [March 10, 2023, 3:00pm UTC](https://forums.swift.org/t/unable-to-exclude-specific-headers-from-a-target/51017/5 "2023-03-10T15:00:56Z")

</div>

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.](https://github.com/KhronosGroup/SPIRV-Cross). I am trying to exclude `include` directory in Package.swift, but SPM still looks into this folder.
