# Where should a Swift package store any SwiftUI Preview data?

**URL:** <https://forums.swift.org/t/where-should-a-swift-package-store-any-swiftui-preview-data/88532>\
**Category:** Using Swift\
**Tags:** packagemanager, swift-package, preview\
**Created:** [July 25, 2026, 4:33am UTC](https://forums.swift.org/t/where-should-a-swift-package-store-any-swiftui-preview-data/88532 "2026-07-25T04:33:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CTMacUser](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ctmacuser/32/1802_2.png) [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Post date:** [July 25, 2026, 4:33am UTC](https://forums.swift.org/t/where-should-a-swift-package-store-any-swiftui-preview-data/88532/1 "2026-07-25T04:33:18Z")

</div>

Yes, Previews are for working with Xcode. but I'm using Xcode to develop the package. I made a separate file because I didn't want to dump 100+ lines for a Preview into the source.

---

<div class="post-metadata">

**Author:** ![andrekandore](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/andrekandore/32/2292_2.png) [@andrekandore](https://forums.swift.org/u/andrekandore)\
**Post date:** [July 26, 2026, 6:31am UTC](https://forums.swift.org/t/where-should-a-swift-package-store-any-swiftui-preview-data/88532/2 "2026-07-26T06:31:41Z")

</div>

if you are using xcode, there is a preview content that is stripped out in release build but i haven't tried that with individual packages

for packages what i usually do is define a `DebugXYZ` target (for each corresponding target) and in xcode configuration set any target to be stripped that contains `DEBUG*` in the `EXCLUDED_SOURCE_FILE_NAMES` or `EXCLUDED_EXPLICIT_TARGET_DEPENDENCIES` (i'm pretty sure that is what preview content is doing behind the scenes)

from apple

> **[Build settings reference | Apple Developer Documentation](https://developer.apple.com/documentation/xcode/build-settings-reference)**
>
> A detailed list of individual Xcode build settings that control or change the way a target is built.

and a helpful explainer

> **[Conditional Compilation, Part 2: Including and Excluding Source Files](https://davedelong.com/blog/2018/07/25/conditional-compilation-in-swift-part-2/)**
>
> In the previous post, we saw how the SWIFT\_ACTIVE\_COMPILATION\_CONDITIONS build setting can inject values in to our .swift files that we can use to conditionalize code depending on our active SDK and/or architecture.

**one additional option**

there is one other way which is to use #if` DEBUG` inline with your previews which will only be active when using xcode (it implicitly defines that for directly included/depended on packages) bit its harder to exclude resources afaict so not so great maybe...
