Is there any way to detect if the build was triggered by the SwiftUI Preview from inside Build Phases - Run Script?
I'm using swiftlint
with --fix --format
, the problem is when I have the Preview open it sometimes triggers a build, which often changes the file while I'm typing, which then brings up the "keep changes/revert" dialog. Keeping the changes often leads Xcode to crash. Ideally, I'd like to do something like this:
if buildWasTriggeredBySwiftUIPreview then
swiftlint
else
swiftlint --fix --format && swiftlint
fi
Thanks to Sweeper, this works: