6

I have a run script build phase I have added to an Xcode project.

I want to be able to toggle this run script on when I want it to run and off when I don't.

Is this possible in Xcode and if so how can it be done?

pkamb
  • 33,281
  • 23
  • 160
  • 191
Mike
  • 10,297
  • 2
  • 21
  • 21
  • What does it do? How do you want to control the on/off status? Can you add it as a different target? – Wain Nov 20 '14 at 20:18
  • You could move the script to a file, have the run script phase be a single line to execute the script in the file. Then, just comment out the single line when you don't want it to run? – Mike Welsh Nov 20 '14 at 22:16
  • I decided to add it as a different target. I set up an Aggregate target and added the run script there so that it would only run when building that target. Thanks! – Mike Nov 21 '14 at 14:13

1 Answers1

2

I used to write exit in the first line to toggle off the script and #exit to toggle on, just like this:

Turn off a script e.g. SwiftLint:

exit
if which swiftlint >/dev/null; then
  swiftlint
else
  echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

Turn on:

#exit
if which swiftlint >/dev/null; then
  swiftlint
else
  echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

You just have to modify 1 character whether exit is commented out or not.

balazs630
  • 3,421
  • 29
  • 46