Edit: Nevermind, this approach “works” but the preview code is still in the final archive, so it doesn’t really help anything.
I put all my preview test data in its own `PreviewProvider` so that I can access it in other Previews. The Archive still succeeds, and the test data will get stripped in the final Archive. No `#if DEBUG` is needed.
Example (specific to my own use case):
struct PreviewData: PreviewProvider {
static var previews: some View {
Text("This is test data for use in other previews.")
}
// Use enums for namespacing if desired
enum Choices {
static let deals = Choice(id: UUID().uuidString, text: "I want the best deals.", iconName: "bestDealsIcon")
static let technology = Choice(id: UUID().uuidString, text: "I love technology!", iconName: "technologyIcon")
}
Then I can access PreviewData.Choices.deals in other PreviewProviders.