In our project, we use the ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS”] method mentioned above for runtime checks for running in previews and for Build Phase scripts for thinks like SwiftLint or SwiftFormat or any script that you don't want to run when compiling for Previews, I discovered the below method that works quite well. I figured this out when watching a build during a Preview build.
if [[ "${CONFIGURATION}" =~ "Debug" && ! "${BUILD_DIR}" =~ "Previews" ]]; then
${PROJECT_DIR}/../../Scripts/swiftlint.sh
fi
Hope this helps someone out!
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: