# Package Manager Conditional Target Dependencies

**URL:** <https://forums.swift.org/t/package-manager-conditional-target-dependencies/31306>\
**Category:** Pitches\
**Tags:** packagemanager\
**Created:** [December 3, 2019, 8:38am UTC](https://forums.swift.org/t/package-manager-conditional-target-dependencies/31306 "2019-12-03T08:38:00Z")\
**Posts on this page:** 1\
**Showing post:** 33

<div class="post-metadata">

**Author:** ![SDGGiesbrecht](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sdggiesbrecht/32/4768_2.png) [@SDGGiesbrecht](https://forums.swift.org/u/SDGGiesbrecht)\
**Post date:** [October 20, 2020, 5:03pm UTC](https://forums.swift.org/t/package-manager-conditional-target-dependencies/31306/33 "2020-10-20T17:03:19Z")

</div>

For the other two libraries, I literally meant enclosing every single file entirely in `#if` so that they successfully build as empty libraries:

```swift
#if os(macOS)
  // All library content here.
#endif

```

Otherwise your hack is still necessary, and there is no proposal in the evolution process yet that would make it otherwise. If you want to improve your hack to also support cross‐compilation, see this post:

> [@SPM build fails for watchOS libraries](https://forums.swift.org/t/spm-build-fails-for-watchos-libraries/40474/10):
>
> This is what I do: Since CI builds are from the command line, I simply have that environment variable set. On the rare occasion something fails only on watchOS, I comment out the if while I’m working and re‐open Xcode. It would be nice to have watchOS automatically evade tests in a similar way to how iOS evades executable targets. (Although even that seems to only work from the GUI and not command line invocations.) But as @NeoNacho said, those are the domain of Xcode, not SwiftPM.

---

_[View the full topic](https://forums.swift.org/t/package-manager-conditional-target-dependencies/31306)._
