Piotr Tobolski
Piotr Tobolski

Reputation: 1406

Xcode SwiftUI Previews build settings

I am running a pre-build script using scheme. My script has enabled option to provide build settings from target that is being built. This script also gets executed when project is built for SwiftUI Previews. I need to know inside this script if the build that is being run is regular one or for previews. Is there a way to do that and how?

I tried running export in the script in both scenarios but it seems that all environment variables are the same in both cases.

Upvotes: 4

Views: 3290

Answers (1)

Asperi
Asperi

Reputation: 257779

It is possible to check ENABLE_PREVIEWS environment variable in scripts.

It is YES for [Build for Previews TARGET]:

demo1

and NO for [Build for TARGET]:

demo2

Tested with Xcode 13.2 / iOS 15.2

Upvotes: 6

Related Questions